Here's a challenge. It was for me.

For all URLs that start with /app (e.g. /app/login, /app/mainmenu,
/app/ball.gif), have all requests go to a servlet for processing. If the
servlet recognizes the URL, perform an action and return the appropriate
output. If the URL is not recognized, treat the URL as a filename and return
the named resource.

Hence, if the URL  /app/login was recognized and requested, the servlet
takes an action on them. If the URL /app/ball.gif was requested, the servlet
doesn't recognize it as an action to be performed, and tries to return the
contents of /app/ball.gif to the user.

I've tried using the servlet-mapping of /app/* and pointing this to the
servlet. While this makes requests go to the servlet, if, within that
servlet, I try to get a request dispatcher to /app/ball.gif and forward
there, I get back into the servlet again , presumably because /app/ball.gif
maps to the servlet. This, of course, creates an recursive infinite loop and
soon the server dies.

One alternative that might work, but seems somehow "wrong" to me is to name
every action in the web.xml file, e.g. individually map /app/login,
/app/logout, /app/dothis, /app/dothat, etc. and then have /app/* for all
other resources. I'd like to avoid this particular solution.

Any bright ideas?


Reply via email to