bundles/org.apache.jasper.glassfish/src/org/apache/jasper/compiler/Generator.java
private void generatePreamble(Node.Nodes page) throws JasperException {

        String servletPackageName = ctxt.getServletPackageName();
        String servletClassName = ctxt.getServletClassName();
        String serviceMethodName = Constants.SERVICE_METHOD_NAME;

        // First the package name:
        genPreamblePackage(servletPackageName);

        // Generate imports
        genPreambleImports();

        // Generate class declaration
        out.printin("public final class ");
        out.print(servletClassName);
        out.print(" extends ");
        out.println(pageInfo.getExtends());
        out.printin(
            "    implements org.apache.jasper.runtime.JspSourceDependent");
        if (!pageInfo.isThreadSafe()) {
            out.println(",");
            out.printin("                 SingleThreadModel");
        }
        out.println(" {");
        out.pushIndent();

        // Class body begins here
        generateDeclarations(page);

        // Static initializations here
        genPreambleStaticInitializers();

        // Class variable declarations
        genPreambleClassVariableDeclarations(servletClassName);

        // Constructor
        //	generateConstructor(className);

        // Methods here
        genPreambleMethods();

        // Now the service method
        out.printin("public void ");
        out.print(serviceMethodName);
        out.println(
            "(HttpServletRequest request, HttpServletResponse response)");
        out.println("        throws java.io.IOException, ServletException {");

        out.pushIndent();
        out.println();

        // Local variable declarations
        out.printil("PageContext pageContext = null;");
        if (pageInfo.isSession())
            out.printil("HttpSession session = null;");

        if (pageInfo.isErrorPage()) {
            out.printil(
                "Throwable exception = org.apache.jasper.runtime.JspRuntimeLibrary.getThrowable(request);");
            out.printil("if (exception != null) {");
            out.pushIndent();
            out.printil(
                "response.setStatus((Integer)request.getAttribute(\"javax.servlet.error.status_code\"));");
            out.popIndent();
            out.printil("}");
        }

        out.printil("ServletContext application = null;");
        out.printil("ServletConfig config = null;");
        out.printil("JspWriter out = null;");
        out.printil("Object page = this;");

        out.printil("JspWriter _jspx_out = null;");
        out.printil("PageContext _jspx_page_context = null;");
        out.println();

        out.printil("try {");
        out.pushIndent();

        out.printin("response.setContentType(");
        out.print(quote(pageInfo.getContentType()));
        out.println(");");

        if (ctxt.getOptions().isXpoweredBy()) {
            out.printil("response.setHeader(\"X-Powered-By\", \"" +
                 Constants.JSP_NAME + "\");");
        }

        out.printil(
            "pageContext = _jspxFactory.getPageContext(this, request, response,");
        out.printin("\t\t\t");
        out.print(quote(pageInfo.getErrorPage()));
        out.print(", " + pageInfo.isSession());
        out.print(", " + pageInfo.getBuffer());
        out.print(", " + pageInfo.isAutoFlush());
        out.println(");");
        out.printil("_jspx_page_context = pageContext;");

        out.printil("application = pageContext.getServletContext();");
        out.printil("config = pageContext.getServletConfig();");

        if (pageInfo.isSession())
            out.printil("session = pageContext.getSession();");
        out.printil("out = pageContext.getOut();");
        out.printil("_jspx_out = out;");
        out.printil("_jspx_resourceInjector = (org.glassfish.jsp.api.ResourceInjector) application.getAttribute(\"com.sun.appserv.jsp.resource.injector\");");
        out.println();
    }
private void generatePreamble(Node.Nodes page) throws JasperException {

        String servletPackageName = ctxt.getServletPackageName();
        String servletClassName = ctxt.getServletClassName();
        String serviceMethodName = Constants.SERVICE_METHOD_NAME;

        // First the package name:
        genPreamblePackage(servletPackageName);

        // Generate imports
        genPreambleImports();

        // Generate class declaration
        out.printin("public final class ");
        out.print(servletClassName);
        out.print(" extends ");
        out.println(pageInfo.getExtends());
        out.printin(
            "    implements org.apache.jasper.runtime.JspSourceDependent");
        if (!pageInfo.isThreadSafe()) {
            out.println(",");
            out.printin("                 SingleThreadModel");
        }
        out.println(" {");
        out.pushIndent();

        // Class body begins here
        generateDeclarations(page);

        // Static initializations here
        genPreambleStaticInitializers();

        // Class variable declarations
        genPreambleClassVariableDeclarations(servletClassName);

        // Constructor
        //	generateConstructor(className);

        // Methods here
        genPreambleMethods();

        // Now the service method
        out.printin("public void ");
        out.print(serviceMethodName);
        out.println(
            "(HttpServletRequest request, HttpServletResponse response)");
        out.println("        throws java.io.IOException, ServletException {");

        out.pushIndent();
        out.println();

        // Local variable declarations
        out.printil("PageContext pageContext = null;");
        if (pageInfo.isSession())
            out.printil("HttpSession session = null;");

        if (pageInfo.isErrorPage()) {
            out.printil(
                "Throwable exception = org.apache.jasper.runtime.JspRuntimeLibrary.getThrowable(request);");
            out.printil("if (exception != null) {");
            out.pushIndent();
            out.printil(
                "response.setStatus((Integer)request.getAttribute(\"javax.servlet.error.status_code\"));");
            out.popIndent();
            out.printil("}");
        }

        out.printil("ServletContext application = null;");
        out.printil("ServletConfig config = null;");
        out.printil("JspWriter out = null;");
        out.printil("Object page = this;");

        out.printil("JspWriter _jspx_out = null;");
        out.printil("PageContext _jspx_page_context = null;");
        out.println();

        out.printil("try {");
        out.pushIndent();

        out.printin("response.setContentType(");
        out.print(quote(pageInfo.getContentType()));
        out.println(");");

        if (ctxt.getOptions().isXpoweredBy()) {
            out.printil("response.setHeader(\"X-Powered-By\", \"" +
                 Constants.JSP_NAME + "\");");
        }

        out.printil(
            "pageContext = _jspxFactory.getPageContext(this, request, response,");
        out.printin("\t\t\t");
        out.print(quote(pageInfo.getErrorPage()));
        out.print(", " + pageInfo.isSession());
        out.print(", " + pageInfo.getBuffer());
        out.print(", " + pageInfo.isAutoFlush());
        out.println(");");
        out.printil("_jspx_page_context = pageContext;");

        out.printil("application = pageContext.getServletContext();");
        out.printil("config = pageContext.getServletConfig();");

        if (pageInfo.isSession())
            out.printil("session = pageContext.getSession();");
        out.printil("out = pageContext.getOut();");
        out.printil("_jspx_out = out;");
        out.printil("_jspx_resourceInjector = (org.glassfish.jsp.api.ResourceInjector) application.getAttribute(\"com.sun.appserv.jsp.resource.injector\");");
        out.println();
    }
private void generatePreamble ( Node . Nodes page ) throws JasperException { String servletPackageName = ctxt . getServletPackageName ( ) ; String servletClassName = ctxt . getServletClassName ( ) ; String serviceMethodName = Constants . SERVICE_METHOD_NAME ; // First the package name: genPreamblePackage ( servletPackageName ) ; // Generate imports genPreambleImports ( ) ; // Generate class declaration out . printin ( "public final class " ) ; out . print ( servletClassName ) ; out . print ( " extends " ) ; out . println ( pageInfo . getExtends ( ) ) ; out . printin ( "    implements org.apache.jasper.runtime.JspSourceDependent" ) ; if ( ! pageInfo . isThreadSafe ( ) ) { out . println ( "," ) ; out . printin ( "                 SingleThreadModel" ) ; } out . println ( " {" ) ; out . pushIndent ( ) ; // Class body begins here generateDeclarations ( page ) ; // Static initializations here genPreambleStaticInitializers ( ) ; // Class variable declarations genPreambleClassVariableDeclarations ( servletClassName ) ; // Constructor //	generateConstructor(className); // Methods here genPreambleMethods ( ) ; // Now the service method out . printin ( "public void " ) ; out . print ( serviceMethodName ) ; out . println ( "(HttpServletRequest request, HttpServletResponse response)" ) ; out . println ( "        throws java.io.IOException, ServletException {" ) ; out . pushIndent ( ) ; out . println ( ) ; // Local variable declarations out . printil ( "PageContext pageContext = null;" ) ; if ( pageInfo . isSession ( ) ) out . printil ( "HttpSession session = null;" ) ; if ( pageInfo . isErrorPage ( ) ) { out . printil ( "Throwable exception = org.apache.jasper.runtime.JspRuntimeLibrary.getThrowable(request);" ) ; out . printil ( "if (exception != null) {" ) ; out . pushIndent ( ) ; out . printil ( "response.setStatus((Integer)request.getAttribute(\"javax.servlet.error.status_code\"));" ) ; out . popIndent ( ) ; out . printil ( "}" ) ; } out . printil ( "ServletContext application = null;" ) ; out . printil ( "ServletConfig config = null;" ) ; out . printil ( "JspWriter out = null;" ) ; out . printil ( "Object page = this;" ) ; out . printil ( "JspWriter _jspx_out = null;" ) ; out . printil ( "PageContext _jspx_page_context = null;" ) ; out . println ( ) ; out . printil ( "try {" ) ; out . pushIndent ( ) ; out . printin ( "response.setContentType(" ) ; out . print ( quote ( pageInfo . getContentType ( ) ) ) ; out . println ( ");" ) ; if ( ctxt . getOptions ( ) . isXpoweredBy ( ) ) { out . printil ( "response.setHeader(\"X-Powered-By\", \"" + Constants . JSP_NAME + "\");" ) ; } out . printil ( "pageContext = _jspxFactory.getPageContext(this, request, response," ) ; out . printin ( "\t\t\t" ) ; out . print ( quote ( pageInfo . getErrorPage ( ) ) ) ; out . print ( ", " + pageInfo . isSession ( ) ) ; out . print ( ", " + pageInfo . getBuffer ( ) ) ; out . print ( ", " + pageInfo . isAutoFlush ( ) ) ; out . println ( ");" ) ; out . printil ( "_jspx_page_context = pageContext;" ) ; out . printil ( "application = pageContext.getServletContext();" ) ; out . printil ( "config = pageContext.getServletConfig();" ) ; if ( pageInfo . isSession ( ) ) out . printil ( "session = pageContext.getSession();" ) ; out . printil ( "out = pageContext.getOut();" ) ; out . printil ( "_jspx_out = out;" ) ; out . printil ( "_jspx_resourceInjector = (org.glassfish.jsp.api.ResourceInjector) application.getAttribute(\"com.sun.appserv.jsp.resource.injector\");" ) ; out . println ( ) ; }
Generates the beginning of the static portion of the servlet.
Generates the beginning of the static portion of the servlet .