Several methods to prevent users from directly accessing JSP pages

Source: Internet
Author: User

Several methods to prevent users from directly accessing JSP pages:
 

1. Put the JSP page under the WEB-INF directory, store everything in this directory or its subdirectory is protected.

However, it is not recommended because not all containers have such protection mechanisms, such as weblogic.


2. Use the servlet filter to filter requests to JSP pages.


3. Use security restrictions in the deployment file web. xml. This is easier than the filter. You do not need to write another filter. The configuration is as follows:

<Security-constraint> <web-resource-collection> <web-resource-Name> JSPs </Web-resource-Name> <URL-pattern>/web/* </URL -Pattern> <! -- Deny direct access to all pages in the web folder --> </Web-resource-collection> <auth-constraint/> </security-constraint> <login-config> <auth- method> basic </auth-method> <! -- Verification Method (Basic/form) --> </login-config>


<Web-resource-Name> qnjyzxt </Web-resource-Name> <! -- Qnjyzxt is the name of the file containing the resource (project name can be used) -->
<URL-pattern>/web/* </url-pattern> <! -- Deny direct access to all pages under the web folder -->


You can also set access restriction roles.

This article introduces restrictions on web resources on JSP pages.


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.