How can I allow the servlet to access a webpage or jsp file under web-inf?

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.