2010/01/11 - Apache Beehive has been retired.

For more information, please explore the Attic.

Apache > Beehive

Frequently Asked Questions

How Do I Ensure that JSPs are Accessible Only Through the Controller Class?

To prevent users from navigating directly to a JSP page, register the following filter class. The filter class will intercept direct requests for JSPs and redirect the user to the Controller class in the JSP's parent directory.

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()

Register the class in WEB-INF/web.xml as shown below: