How do I get the servlet to access a Web page or JSP file under Web-inf? Because Web-inf, the application server refers to it as a banned directory, which is not accessible directly in the browser.
Because of this, you can have a servlet access, such as Web-inf under the a.jsp can be used Request.getrequestdispatcher ("/web-inf/a.jsp"). Forward (Request,response); For dispatch access. But if there are a.htm under Web-inf, then use Request.getrequestdispatcher ("/web-inf/a.htm"). Forward (Request,response);
At first I thought it was strange. Then think about, JSP is also a servlet, will automatically compile, so the work directory will have/web-inf/a$jsp.class type, so there is a clue, so that the application server can compile. htm, such as a$ Htm.class. Hold the idea and start to do it
Conf/web under Tomcat, find the way to access the JSP,
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
So add the following
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
Results: All OK, access to a.htm, and a.html under work/web-inf/have A$htm.class,a$html.class generated </