• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

sending sendRedirect() into an infinite loop

 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
http://www.myapp.com/SHOW/1/Mike.Curwen
http://www.myapp.com/SHOW/2/Big.Moose
http://www.myapp.com/SHOW/admin
http://www.myapp.com/SHOW/reports

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 http://www.myapp.com/SHOW/1/Mike.Curwen

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 http://www.myapp.com/SHOW/1/Mike.Curwen translates to /SHOW/1 as an application 'root', instead of the expected (?) /SHOW/. So then of course, http://www.myapp.com/SHOW/1/foo?etcetc 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?

detail:
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 ]
 
grapes are vegan food pellets. Eat this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic