How to Protect Your JSP page

Source: Internet
Author: User

To better protect your JSP against unauthorized access and peeping, a good way is to store the page file under the WEB-INF directory of the Web application.

Generally, JSP developers store their page files in the corresponding subdirectories of the Web application. A typical Store applicationProgramDirectory structure 2. JSP related to catalog is saved in the catalog subdirectory. JSP related to customer and JSP related to order are stored in this way.

The problem with this method is that these page files are easy to peek.Source codeOr directly called. In some cases, this may not be a big problem, but it may constitute a security risk in specific circumstances. It is also a problem that users can bypass struts controller to directly call JSP.

To reduce risk, you can move these page files to the WEB-INF directory. Servlet-based declarations do not make WEB-INF part of the Common Document Tree for Web applications. Therefore, the resources under the WEB-INF directory are not serving the customer directly. We can still use the JSP page under the WEB-INF directory to provide the view to the customer, but the customer cannot directly request access to JSP.

Using the previous example, Figure 3 shows the directory structure after moving the JSP page to the WEB-INF directory

If you move these JSP page files to the WEB-INF directory, you must add "WEB-INF" to the URL when calling the page. For example, write an action mapping for a logoff action in a struts configuration file. The JSP path must start with "WEB-INF. Note the bold Section as follows.

This method is a good method in struts practice under any circumstances. The only trick to note is that you must associate JSP with a struts action. Even if this action is just a very basic JSP, it always calls an action and then calls JSP.

It should be noted that not all containers support this feature. WebLogic earlier versions do not support servlet declarations, so it is reported that they have been improved in the new version. Check your servlet container before using it.

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.