Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

sending sendRedirect() into an infinite loop  RSS feed

Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is easier than I thought...

I have Apache Web Server set up thusly:

Then in Tomcat server.xml:
And finally in the web.xml for the application in question:
So I think you can see with this setup, I have something like this:

The /admin and /reports requests will map to other 'known' servlets in web.xml (and these work properly).

Anything 'not' recognized will be picked up by my Translating servlet. (the default servlet) It expects certain formats.. meaning #/FirstName.LastName

Never mind the robustness of that.. here is the code within the translator (the code of interest)
So I'm translating from a #/FirstName.LastName format into a queryString that all other parts of my application can use.

Here is what I get when I make a request for

If I start my newURL (the translated URL) with "/foo?", then this will tell the container to translate the redirect relative to the container root. I don't want that, I want the application root. So I leave it as "foo?". (I've tried it both ways: /foo? gives me a 404, and I'm missing the "/SHOW" token. But if I leave it off.... I get an infinite loop.
It's almost as though somehow the container is determining that translates to /SHOW/1 as an application 'root', instead of the expected (?) /SHOW/. So then of course, is 'unrecognized' and I go through the Translator again.

The 2nd (and subsequent) calls to handleRequest() will attempt to parse foo?etcetc as a FirstName.LastName, and right now I have it defaulting to a test user (uid=0) when it can't find one.

Am I right in thinking "The container is responsible for turning relative URLs into absolute URLs". I sorta recall reading it somewhere. In this case though, it is not translating them correctly.

Might this be a bug in JK ? In Tomcat? Or is this the expected behaviour?

Apache/2.0.45 (Unix) mod_jk/1.2.3
Tomcat 4.1.24
JDK 1.4.1
[ July 15, 2003: Message edited by: Mike Curwen ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!