Search your topic in Java2share
Home > FAQs
eXTReMe Tracker


JSP FAQs


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.

2 . Explain the benefits of JSP?
These are some of the benefits due to the usage of JSP they are:
Portability, reusability and logic components of the language can be used across various platforms.
Memory and exception management.
Has wide range of API which increases the output functionality.
Low maintenance and easy deployment.
Robust performance on multiple requests.


3. Is JSP technology extensible?
Yes, it is. JSP technology is extensible through the development of custom actions, or tags, which are encapsulated in tag libraries.

4 .Can we implement an interface in a JSP?

No
5 What are the advantages of JSP over Servlet?

  1. Best suitable for view components
  2. we can separate presentation and business logic
  3. The JSP author not required to have strong java knowledge
  4. If we are performing any changes to the JSP, then not required to recompile and reload explicitly
  5. We can reduce development time.

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:

  1. JspPage:

         This interface defines the two life cycle methods jspInit() and jspDestroy().

  1. HttpJspPage:

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.