Jsp includ summary javax.servlet.ServletException: File amp;quot;/demo/header.jsp" not found

tags: javax.servlet.ServletException: Fil  jsp include

javax.servlet.ServletException: File amp;quot;/demo/header.jsp" not found

wrong reason

<jsp:include page="${ctx}/header.jsp"></jsp:include>
${ctx}Is the project name, set on the login page<c:set var="ctx" scope="application" value="${pageContext.request.contextPath}"/>
Note: If you use the idea to deploy without specifying the project name, you can access it successfully.${ctx}="/"

solve

use<%@include file="/header.jsp"%>replace<jsp:include page="${ctx}/header.jsp"/>

why

When the jsp foreground is displayed, it will be translated into a Servlet first, and then used.javax.servlet.http.HttpServletResponse responseShow at the front desk

<jsp:include page="${ctx}/header.jsp"/>

<jsp:include/>manual

  1. When there is jsp use<jsp:include page="${ctx}/header.jsp"></jsp:include>Turn the user intoServlet
  2. Putheader.jspFirst translated intoServlet
  3. userServletMedium configurationheader.jspofServlet

verification
under Tomcat\work\Catalina\localhostCan be found underheader_jsp.javaFile, the user also has a corresponding file, open to see

 org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, (java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${ctx}/header.jsp", java.lang.String.class, (javax.servlet.jsp.PageContext)_jspx_page_context, null, false), out, false);

Reference header.jsp in the servlet
<%@include%>The code is introduced, the code is included, and when new JSP is added, it will be generated by default.

<%@include file="/header.jsp"%>

<%@include%>manual

  1. Introducing header.jsp in jsp file
  2. User translation servlet

View jsp translated files and found noheader_jsp.java, can be seen in the user

	  out.write("\r\n");
	  ···
	  ···
	  ···
     /**
     *Content in the header.jsp file
     */
      out.write("</head>");

to sum up

the difference include jsp:include
execution time Translation stage Executed during the request processing phase
Introduced content Introduce static text,First include, post-compilation Introduce the response text generated by the execution page or servlet. The included fileCompile first, then includeCome in, then show

Translation stage:

The jsp page cannot be transferred to the browser as it is, and all jsp elements must be processed by the server first. This is done by translating the jsp page into a servlet and then executing the servlet. The server needs a jsp container to handle the jsp page. The jsp container is usually implemented in the form of a servlet that is configured to handle all requests to the jsp page.
The Jsp container also converts the jsp page into a servlet (called the JSP Page implementation class) and compiles the servlet. These two steps form the translation phase.

Request processing phase:

In addition to the above mentioned Jsp container to convert the jsp page into a servlet, it also calls the jsp page implementation class to process each request and generate a response. This stage is called the request processing stage. The request processing stage only executes the class documentation.

Intelligent Recommendation

HTTP Status 500 - javax.servlet.ServletException: File [/head.jsp] not found

Complete error message HTTP Status 500 - javax.servlet.ServletException: File [/head.jsp] not found type Exception report message javax.servlet.ServletException: File [/head.jsp] not found description...

[Switch] Compile C++ file &amp;quot;hello world with Visual Studio2010

I started learning C++ language this week, using Visual Studio 2010 as a compiler, and found that there is no basic textbook on compiling programs with VS2010. And when you look online, the tutorial i...

Input.GetAxis(&amp;quot;&amp;quot;) Input.GetAxisRaw(&amp;quot;&amp;quot;)

Input.GetAxis Get axis static function GetAxis (axisName : string) : float Descriptiondescription Returns the value of the virtual axis identified by axisName. Returns the value in the ...

Error:(12, 8) java: Unable to access javax.servlet.ServletException Class file for javax.servlet.ServletException not found

Error:(12, 8) java: Unable to access javax.servlet.ServletException Cannot find class file for javax.servlet.ServletException Need to add servlet dependencies or...

JSP&amp;Servlet learning summary

What have I done in these 20 days? In addition to class, playing badminton, playing games, learning JSP&Servlet, reviewing sql, Ubuntu, decided to use it as an online poker game.howeverMaybe becau...

More Recommendation

HF servlet &amp; jsp summary - scriptless JSP

8 scriptless JSP 8.1 Using Action Elements on JSP Pages If the useBean can't find a bean called person, it will create such a class by itself, and look at the code in the generated servlet: But the be...

HF servlet &amp; jsp summary - using JSP

At first glance, the servlet&jsp servlet of the HF series did not have time to summarize. In the future, I will start with "using jsp", do a summary, share it with everyone, and review i...

Servlet &amp; jsp upload file

However, java.io.FileNotFoundException is reported when running: c:\temp\test.txt (The system cannot find the specified path.) After troubleshooting, it is found that the corresponding directory is no...

Attribute &amp;quot;alisa&amp;quot; must be declared for element type &amp;quot;typeAlias&amp;quot;.

Learning mybatis, just started writing profiles mybatis-config.xml ,, when the top copy and paste alisa error: Attribute "alisa" must be declared for element type "typeAlias" Worka...

The declared package &amp;quot;com.how2java.j2se&amp;quot; does not match the expected package &amp;quot;&amp;quot;

The declared package "com.how2java.j2se" does not match the expected package "" I encountered this error, because the first written document, after loading the server caused it, de...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top