How can I allow the servlet to access the webpage or JSP file under Web-INF. in web-INF, the application server regards it as a forbidden directory, that is, it cannot be accessed directly in the browser.
For some reasons, Servlet access is allowed, such as. JSP can use request. getrequestdispatcher ("/Web-INF/. JSP "pai.forward(request,response?dispatch dispatch. However, if there is a.htm under web-infa, request is used. getrequestdispatcher ("/Web-INF/a.htm "). forward (request, response); cannot be accessed.
I cannot figure it out at first. later, I thought that JSP is actually a Servlet and will be automatically compiled, so there will be/Web-INF/aw.jsp.class.pdf in the work directory, so that the application server can compile and translate .htm, such as a $ htm. class. start with this idea
Find the JSP access method in CONF/web under tomcat,
<Servlet-mapping>
<Servlet-Name> JSP </servlet-Name>
<URL-pattern> *. jsp </url-pattern>
</Servlet-mapping>
Add
<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>
Result: A $ htm. class and a $ html. Class are generated under work/Web-INF /.