Web-inf Mutual access between JSP under protected directory __js

Source: Internet
Author: User
Tags stub

We said that the Web-inf directory has *.xml classes lib directories and files, they are generally not let direct access.

Description of this directory is safe, we recall why not JSP, HTML and other page files into it.

Will it be safer? It's a good guess, it's safe (you can do this with a filter),

There is a path problem that needs to be resolved, using page entry issues, if the paging file is placed in the Web-inf directory, the user accesses

Web-inf Directory page file will be unable to find the page, users how to access the site page.

If the liandong.jsp is placed in the web-inf/jsp directory, the Web context-root is: Liandong so

1. We can create a new index.jsp under Webroot, where the code is:

<jsp:forward page= "web-inf/jsp/liandong.jsp" ></jsp:forward>

2. We can configure code in Struts-config.xml:

<action path= "/test" scope= "Request"
Type= "Org.springframework.web.struts.DelegatingActionProxy" >
<forward name= "Liandong" path= "/web-inf/jsp/liandong.jsp" ></forward>
</action>

The code in the action is:

@Override
Public Actionforward Execute (actionmapping mapping, Actionform form,
HttpServletRequest request, HttpServletResponse response)
Throws Exception {
TODO auto-generated Method Stub
Method 2
Return Mapping.findforward ("Liandong");
}

index.jsp code is: <a href= "Test.do" >link-->liandong</a>

3. We can write code in action:

@Override
Public Actionforward Execute (actionmapping mapping, Actionform form,
HttpServletRequest request, HttpServletResponse response)
Throws Exception {
TODO auto-generated Method Stub
System.out.println ("BBB");
RequestDispatcher rd = Request.getrequestdispatcher ("web-inf/jsp/liandong.jsp");

Rd.forward (Request,response);

return null;
}

index.jsp code is: <a href= "Test.do" >link-->liandong</a>

Struts-config.xml Configuration Code:

<action path= "/test" scope= "Request"
Type= "Org.springframework.web.struts.DelegatingActionProxy" >
<forward name= "Liandong" path= "/web-inf/jsp/liandong.jsp" ></forward>
</action>

4.action Medium

@Override
Public Actionforward Execute (actionmapping mapping, Actionform form,
HttpServletRequest request, HttpServletResponse response)
Throws Exception {
TODO auto-generated Method Stub
System.out.println ("BBB");

return new Actionforward ("/web-inf/jsp/liandong.jsp");
}

index.jsp code is: <a href= "Test.do" >link-->liandong</a>

Struts-config.xml Configuration Code:

<action path= "/test" scope= "Request"
Type= "Org.springframework.web.struts.DelegatingActionProxy" >
<forward name= "Liandong" path= "/web-inf/jsp/liandong.jsp" ></forward>
</action>

Another problem is that cascading style files, JS script files, picture file paths

1. Page Access pictures

Background-image:url ('/liandong/images/bg.bmp ')

2. Page access cascading style files

<link rel= "stylesheet" href= "/liandong/css/liandong.css" type= "Text/css" ></link>

3. Page Access JS script file

<script type= "Text/javascript" src= "/liandong/js/liandong.js" ></script>

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.