1. What is JSP ? Describe its concept.
Java Server Pages (JSP) is a server side component for the generation of dynamic information as the response. Best suitable to implement view components (presentation layer components). It is part of SUN’s J2EE platform.
4 .Can we implement an interface in a JSP?
No
5 What are the advantages of JSP over Servlet?
6. Differences between Servlets and JSP?
Servlets |
JSP |
1. Best suitable for processing logic |
1. Best suitable for presentation logic |
2. we cannot separate business and presentation logic |
2. Separation of presentation and business logic is possible |
3. Servlet developer should have strong knowledge in Java |
3.JSP author is not required to have strong knowledge in Java |
4. For source code changes ,we have to perform explicitly compilation |
4. For source code changes ,it is not required to perform explicit compilation |
5. Relatively development time is more |
5. Relatively development time is less |
7 . Explain the differences between ASP and JSP?
The big difference between both of these technologies lies with the design of the software. JSP technology is server and platform independent whereas ASP relies primarily on Microsoft technologies.
8 . Can I stop JSP execution while in the midst of processing a request?
Yes. Preemptive termination of request processing on an error condition is a good way to maximize the throughput of a high-volume JSP engine. The trick (assuming Java is your scripting language) is to use the return statement when we want to terminate further processing.
9. How to Protect JSPs from direct access ?
If the JSP is secured resource then we can place inside WEB-INF folder so that end user is not allowed to access directly by the name. We can provide the url pattern by configuring in web.xml
<web-app>
<servlet>
<servlet-name>Demo JSP</servlet-name>
<jsp-file>/WEB-INF/test.jsp</jsp-file>
<sevlet>
<servlet-mapping>
<servlet-name>Demo JSP</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>
..
</web-app>
10. Explain JSP API ?
The JSP API contains only one package : javax.servlet.jsp
It contains the following 2 interfaces:
This interface defines the two life cycle methods jspInit() and jspDestroy().
This interface defines only one life cyle method _jspService() method.
Every generated servlet for the jsps should implement either JspPage or HttpJspPage interface either directly or indirectly.