javax.servlet.ServletException: File "/xml/hyperLinkList.jsp" not found

The error message is as follows: Everyone brainstorms

Later I found the reason for the error:

<jsp:include page=" ${pageContext.request.contextPath} /hyperLinkList.jsp"></jsp:include> This sentence causes an error, because the EL expression is used here, ${pageContext.request.contextPath } This EL expression causes an error, because the sentence <jsp:include page=" ${pageContext.request.contextPath} /hyperLinkList.jsp"></jsp:include> is written in the home.jsp page,


And we know that jsp will eventually be translated into a Servlet, we can go and see the translated Servlet of the home.jsp page . In the tomcat directory\work\Catalina\localhost\your project name\org\apache\jsp directory, you can find this servlet translated from the home.jsp page , named home_jsp.java .


Open the file home_jsp.java, you can see the following code, the sentence <jsp:include page=" ${pageContext.request.contextPath} /hyperLinkList.jsp"></jsp:include> in the home.jsp page After being translated , it will become the following line of code, as shown in the figure: PageContextImpl.proprietaryEvaluate(

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


So I guess, it should be the error caused by this ${pageContext.request.contextPath}. I guess when translating home.jsp into Servlet, as long as there is an EL expression, it will be given after the final parsing is completed. where EL expressions appear

Double quotation marks ( " ) are added to both sides of the square , which leads to the problem that File " /xml/hyperLinkList.jsp " not found file path cannot be found. The sentence ${pageContext.request.contextPath} is to get the project name, you can also understand it as the root directory of the project, some people call it a virtual path.

The name of my project is called xml, so the sentence ${pageContext.request.contextPath} gets /xml, so the sentence ${pageContext.request.contextPath} /hyperLinkList.jsp is finally translated as / xml / hyperLinkList .jsp

As I guessed above,

When translating home.jsp into Servlet, as long as the place where the EL expression appears, the place where the EL expression appears after the final parsing is completed will be given.

Double quotation marks ( " ) are added to both sides of the square , so it is finally translated into the path of "/xml/hyperLinkList.jsp", and our project is not called "/xml/hyperLinkList.jsp" A page with this name! This is the reason for the error, which is my guess! This is not necessarily the case, please advise experts! Thanks!

The next thing we have to do is to remove the EL expression ${pageContext.request.contextPath} , OK, we change it to

<jsp:include page="/hyperLinkList.jsp"></jsp:include>


The picture after translation is as follows: Obviously, after removing the EL expression of ${pageContext.request.contextPath} , the classes used after translation are different.

The following figure uses JspRuntimeLibrary.include(


Then we will open the home.jsp page in the browser and no error will be reported!


Note: The include directive does not support EL expressions - <%@include file="${pageContext.request.contextPath}/hyperLinkList.jsp" %> This is not supported and will report an error HTTP Status 500 - /testInclude.jsp (line : 50, column: 2) 


File "${pageContext.request.contextPath}/hyperLinkList.jsp" not found

The use of EL expressions in the include action is prone to errors, - <jsp:include  page="${pageContext.request.contextPath}/hyperLinkList.jsp" ></ jsp:include > This writing method will report an error HTTP Status 500 - javax.servlet. ServletException:  File "/xml/hyperLinkList.jsp" not found The include action (jsp:include) supports EL expressions, but like < jsp:include  page="${pageContext.request.contextPath}/SaveData2 " > </ jsp:include > This way of writing the servlet path will result in an additional project name path  after parsing , java.io.FileNotFoundException: The requested resource (/xml/xml/SaveData2) is not available, which will eventually lead to inability to find The page attribute to the file include action (jsp:include) supports jsp, html and servlet path writing










The file attribute of the include directive (@include) only supports pages such as jsp and html. It does not support the Servlet path, nor does it support the writing method
of EL expressions. EL expressions are used in include (include). You must pay more attention and be careful.

type Exception report

message javax.servlet.ServletException: File "/xml/hyperLinkList.jsp" not found

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: javax.servlet.ServletException: File "/xml/hyperLinkList.jsp" not found
	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:585)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

root cause

javax.servlet.ServletException: File "/xml/hyperLinkList.jsp" not found
	org.apache.jasper.servlet.JspServlet.handleMissingResource(JspServlet.java:412)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:379)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
	org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:954)
	org.apache.jsp.home_jsp._jspService(home_jsp.java:246)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
	org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.53 logs.


Apache Tomcat/7.0.53


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325979625&siteId=291194637