How to call JSP 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.