JSP.C.3 The Servlet for the Compiled JSP Page


As an alternative, we will show how one can compile the JSP page into a servlet class to run in a JSP container.

The JSP page is compiled into a servlet with some implementation-dependent name _jsp_HelloWorld_XXX_Impl . The servlet code depends only on the JSP 1.1 and Servlet 2.2 APIs, as follows :

 imports javax.servlet.*;  imports javax.servlet.http.*;  imports javax.servlet.jsp.*;  class _jsp_HelloWorld_XXX_Impl extends_PlatformDependent_Jsp_Super_Impl {    public void _jspInit() {            // ...     }     public void jspDestroy() {            // ...     }     static JspFactory_factory= JspFactory.getDefaultFactory();     public void _jspService(HttpServletRequest request,                     HttpServletResponse response)                 throws IOException, ServletException     {             Object   page = this;              HttpSessionsession= request.getSession();              ServletConfigconfig= getServletConfig();              ServletContextapplication = config.getServletContext();              PageContextpageContext                  = _factory.getPageContext(this,                               request,                               response,                               (String)NULL,                               true,                               JspWriter.DEFAULT_BUFFER,                               true                               );              JspWriter out = pageContext.getOut();                  // page context creates initial JspWriter "out"              try {                 out.println("<p>");                  out.println("Hello World");                  out.println("</p>");              } catch (Exception e) {                 pageContext.handlePageException(e);              } finally {                 _factory.releasePageContext(pageContext);              }     }  } 


Java 2 Platform, Enterprise Edition. Platform and Component Specifications
Java 2 Platform, Enterprise Edition: Platform and Component Specifications
ISBN: 0201704560
EAN: 2147483647
Year: 2000
Pages: 399

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net