Considerations for JSP placed under Web-inf

Source: Internet
Author: User

Web-inf directory is not open to the outside, external no way directly access to. All can be accessed only through mappings, such as mapping to an action or a servlet accessing a specific page through a server-side jump. This can limit access and improve security.

1, the page resource files can only be placed under the Webroot, such as Css,js,image and so on. It can't be quoted under Web-inf.

2, can only use the steering way to access the JSP in the Web-inf directory, do not have to redirect the way to request any resources in the directory.

3, Web-inf directory when the file access resource files, you can ignore Web-inf this layer of directory. If index.jsp want to use a CSS file in the CSS directory. <link rel= "stylesheet" type= "Text/css" href= " css/**.css"/> That's it, okay? From the client's address you can see that the server steering index.jsp is under Webroot. So index.jsp and CSS directories can be said to be the same level directory.

4, how to access the files in the Web-inf directory, such as in main.jsp with <a href= "oa.do " > Test OA path </a> access. If main.jsp has a lot of links to other pages in the Web-inf directory. Then there must be 10 steering action. This can be done with the Dispatchaction class plus parameters specifically for steering.

NOTE: Steering mode: Configure <forward Name= "Success" Path= "/web-inf/main.jsp" in Struts-config files/>

or write Request.getrequestdispatcher ("/web-inf/main.jsp") in action. Forward (request, response);

The server reads the contents of the page and sends it to the client. The address of the client is unchanged. Content Jumps


REDIRECT mode: Configure <forward Name= "Success" Path= "/web-inf/main.jsp" redirect= "true"/> as in the Struts-config file

or Response.sendredirect ("/error.jsp") in action;

The meaning of redirection is that the server sends the address to the client and allows the client to access it. This approach clearly targets the Web-inf directory as useless.

Considerations for JSP placed under Web-inf

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.