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 /.