Is there a way to do the following?

Let's say a user requests /foo/junk.gif, or /foo/test.jsp.

I'd like all requests to /foo/* to first be processed by a servlet.  
The servlet performs some operation (user authentication specifically).  
If the servlet processing performs normally, I want the request forwarded to
the page actually requested (in the case of .jsp files, the page must be
processed by the jsp engine first of course).

I've set my Tomcat 3.1 up as defined below.  The result is an infinite loop.
A request of /foo/junk.gif is redirected to the servlet and then to
/foo/junk.gif (which then is redirected to the servlet and then to
/foo/junk.gif... and so on).

Thanks so much for your help!

...Casey

---------------------------------------------------------------

Given a file at webapps/foo/junk.gif

And the following in server.xml : (Maps /foo urls to the middle_serv
context)
        <Context path="/foo" docBase="webapps/middle_serv" debug="0"
reloadable="true" ></Context

And the following in webapps/foo/web-inf/web.xml : (Maps *.gif to the
servlet middleServlet)
        <servlet>
                <servlet-name>
                        middle_serv
                </servlet-name>
                <servlet-class>
                        middleServlet
                </servlet-class>
        </servlet>
        <servlet-mapping>
                <servlet-name>
                        middle_serv
                </servlet-name>
                <url-pattern>
                        *.gif
                </url-pattern>
        </servlet-mapping>

And a servlet called middleServlet: 
        public void doGet (HttpServletRequest request, HttpServletResponse
response) {
                try {
                        // Perform user authentication.. on failure, go to
login page... otherwise proceed

                        // Determine the originally requested URL and
forward the user to that page
                        String orig_url = request.getRequestURI();
        
getServletConfig().getServletContext().getRequestDispatcher(orig_url).forwar
d(request, response);
                } catch (Exception ex) {
                        ex.printStackTrace ();
                }       
        }

==============================================
Casey Bragg - Software Engineer
Allegiance Telecom, Inc.  Dallas, TX
214-261-8679 - [EMAIL PROTECTED]
==============================================

Reply via email to