MCPcopy Index your code
hub / github.com/apache/tomcat / generatePreamble

Method generatePreamble

java/org/apache/jasper/compiler/Generator.java:689–820  ·  view source on GitHub ↗

Generates the beginning of the static portion of the servlet.

(Node.Nodes page)

Source from the content-addressed store, hash-verified

687 * Generates the beginning of the static portion of the servlet.
688 */
689 private void generatePreamble(Node.Nodes page) throws JasperException {
690
691 String servletPackageName = ctxt.getServletPackageName();
692 String servletClassName = ctxt.getServletClassName();
693 String serviceMethodName = ctxt.getOptions().getServiceMethodName();
694
695 // First the package name:
696 genPreamblePackage(servletPackageName);
697
698 // Generate imports
699 genPreambleImports();
700
701 // Generate class declaration
702 out.printin("public final class ");
703 out.print(servletClassName);
704 out.print(" extends ");
705 out.println(pageInfo.getExtends());
706 out.printin(" implements org.apache.jasper.runtime.JspSourceDependent,");
707 out.println();
708 out.printin(" org.apache.jasper.runtime.JspSourceImports");
709 out.println(",");
710 out.printin(" org.apache.jasper.runtime.JspSourceDirectives");
711 out.println(" {");
712 out.pushIndent();
713
714 // Class body begins here
715 generateDeclarations(page);
716
717 // Static initializations here
718 genPreambleStaticInitializers();
719
720 // Class variable declarations
721 genPreambleClassVariableDeclarations();
722
723 // Methods here
724 genPreambleMethods();
725
726 // Now the service method
727 out.printin("public void ");
728 out.print(serviceMethodName);
729 out.println(
730 "(final jakarta.servlet.http.HttpServletRequest request, final jakarta.servlet.http.HttpServletResponse response)");
731 out.pushIndent();
732 out.pushIndent();
733 out.printil("throws java.io.IOException, jakarta.servlet.ServletException {");
734 out.popIndent();
735 out.println();
736
737 // Method check
738 if (!pageInfo.isErrorPage()) {
739 out.printil("if (!jakarta.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) {");
740 out.pushIndent();
741 out.printil("final java.lang.String _jspx_method = request.getMethod();");
742 out.printil("if (\"OPTIONS\".equals(_jspx_method)) {");
743 out.pushIndent();
744 out.printil("response.setHeader(\"Allow\",\"GET, HEAD, POST, OPTIONS\");");
745 out.printil("return;");
746 out.popIndent();

Callers 1

generateMethod · 0.95

Calls 15

genPreamblePackageMethod · 0.95
genPreambleImportsMethod · 0.95
generateDeclarationsMethod · 0.95
genPreambleMethodsMethod · 0.95
getMessageMethod · 0.95
quoteMethod · 0.95
getServletPackageNameMethod · 0.80
getServletClassNameMethod · 0.80
printinMethod · 0.80

Tested by

no test coverage detected