Author: steveh
Date: Wed May 18 10:04:34 2005
New Revision: 170776
URL: http://svn.apache.org/viewcvs?rev=170776&view=rev
Log:
Adding a FAQ on redirecting JSP requests to the Controller class.
Added:
incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/pageflow/faq.xml
(with props)
Modified:
incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/site.xml
Added:
incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/pageflow/faq.xml
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/pageflow/faq.xml?rev=170776&view=auto
==============================================================================
---
incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/pageflow/faq.xml
(added)
+++
incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/pageflow/faq.xml
Wed May 18 10:04:34 2005
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN"
"http://forrest.apache.org/dtd/document-v20.dtd">
+<document>
+ <header>
+ <title>Frequently Asked Questions</title>
+ </header>
+ <body>
+ <section><title>How Do I Ensure that JSP Pages are Accessible Only
Through the Controller Class?</title>
+ <p>To prevent users from navigating directly to a JSP
+page, register the following filter class. The filter class will intercept
direct requests for JSP pages
+and redirect the user to the Controller class in the JSP's parent directory.
</p>
+<source>package example;
+
+import java.io.IOException;
+import javax.servlet.*;
+import javax.servlet.http.*;
+
+public class JspToPageFlowFilter implements Filter
+{
+ public void doFilter( ServletRequest request, ServletResponse response,
FilterChain chain )
+ throws IOException, ServletException
+ {
+ // Redirect to the begin method in the parent directory
+ String pagePath = ( ( HttpServletRequest ) request ).getContextPath()
+ ( ( HttpServletRequest ) request ).getServletPath();
+ int lastSlash = pagePath.lastIndexOf( '/' );
+ String parentDir = pagePath.substring( 0, lastSlash + 1 );
+ String beginAction = parentDir + "begin.do";
+ ( ( HttpServletResponse ) response ).sendRedirect( beginAction );
+ }
+
+ public void init( FilterConfig filterConfig )
+ throws ServletException
+ {
+ }
+
+ public void destroy()
+ {
+ }
+}</source>
+<p>Register the class in <code>WEB-INF/web.xml</code> as shown below:</p>
+<source> <filter>
+ <filter-name>JspToPageFlowFilter</filter-name>
+ <filter-class>example.JspToPageFlowFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>JspToPageFlowFilter</filter-name>
+ <url-pattern>*.jsp</url-pattern>
+ <dispatcher>REQUEST</dispatcher>
+ </filter-mapping></source>
+ </section>
+ </body>
+ <footer>
+ <legal>Java, J2EE, and JCP are trademarks or registered
trademarks of Sun Microsystems, Inc. in the United States and other
countries.<br/>
+ © 2004, Apache Software Foundation
+ </legal>
+ </footer>
+</document>
Propchange:
incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/pageflow/faq.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/site.xml
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/site.xml?rev=170776&r1=170775&r2=170776&view=diff
==============================================================================
---
incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/site.xml
(original)
+++
incubator/beehive/trunk/docs/forrest/src/documentation/content/xdocs/site.xml
Wed May 18 10:04:34 2005
@@ -40,6 +40,7 @@
<pageflow_jsf label="Java Server Faces" href="pageflow/jsf.html"/>
<pageflow_servlet_adapter label="Servlet Container Adapters"
href="pageflow/servlet_container_adapters.html"/>
<devmode label="Development Mode"
href="development/dev_mode.html"/>
+ <pageflow_faq label="FAQ" href="pageflow/faq.html"/>
<!--<pageflow_programming label="Page Flow Programming"
href="pageflow/guide.html"/>-->
</pageflow>
<controls label="Controls">