How to insert jsp pages under a WEB-INF into frameset

Source: Internet
Author: User

In my graduation project, I put all the jsp pages in the WEB-INF folder. However, a problem occurs. WEB-INF is a protected folder, and we cannot access the resources in it through the regular method, that is, if we write the following code in frameset, it cannot be accessed:

1 <frame src="/WEB-INF/page/admin_righr.jsp" name="main" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto"/>


The above code reports a 404 error.

 

So how can we solve this problem? There are three solutions:

I. Use Struts Framework

1. When src is configured in the frame, point it to an action.

1 <frame src="${pageContext.request.contextPath }/adminIndex/toAdmin_toAdminRight.action" name="main" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto"/>

 

2. Return a string in the processing method. Then point to the jsp file to be loaded when processing results in struts. xml.

1     /**2      * admin_right.jsp3      */4     public String toAdminRight(){5         return "adminRight";6     }
1 <package name="adminIndex" namespace="/adminIndex" extends="struts-default">2         <action name="toAdmin_*" class="adminIndexAction" method="{1}">3         <result name="adminRight">/WEB-INF/page/backstage/admin_right.jsp</result>4         </action>5     </package>


Ii. Use Servlet

1 <servlet>2   <servlet-name>servletName</servlet-name>3   <jsp-file>/WEB-INF/admin_right.jsp>4 </servlet>5 <servlet-mapping>6   <servlet-name>servletName</servlet-name>7   <url-pattern>/.do</url-pattern>8 <servlet-mapping>

Then you can point to the servlet.

 

3. Use <jsp: forward page = "WEB-INF/XXX"> to directly access the jsp under the web-inf directory.

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.