Sorry for posting this here, but I either have a pretty big
misunderstanding of something (most likely) or I've discovered a bug????
 
I have Apache Web Server set up thusly:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<VirtualHost xxx.xxx.xxx.xxx>
      DocumentRoot /home/webhome/myapp/
      ServerName www.myApp.com
      ErrorLog /var/log/myapp/error_log
      CustomLog /var/log/myapp/access_log combined
</VirtualHost>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Then in Tomcat server.xml:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<Context path="/SHOW" docBase="/home/webhome/myapp/"
defaultSessionTimeout="60">
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

And finally in the web.xml for the application in question: 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        <servlet>
                <servlet-name>Trans</servlet-name>
                <servlet-class>com.acme.Translator</servlet-class>
                <load-on-startup>0</load-on-startup>
        </servlet>
.
.
.
        <servlet-mapping>
          <servlet-name>Trans</servlet-name>
          <url-pattern>/</url-pattern>
        </servlet-mapping>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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/Other.Person
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)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public void handleRequest( HttpServletRequest request,
HttpServletResponse response) throws Exception {

        HttpSession session = request.getSession(true);

        logger.debug("URI: " + request.getRequestURI());
        logger.debug("URL: " + request.getRequestURL());
        logger.debug("PATH: " + request.getPathInfo());


        String what_was_requested = request.getRequestURI();

        String newURL=("foo?");
        
        // large block of code snipped ... it translates the 
        // 'encoded' request into a normalized querystring
        // for the 'foo' servlet.

        newURL = response.encodeRedirectURL(newURL);
        logger.debug("SHOW:: " + request.getRequestURI() + " translates
to: " + newURL);
        // redirect (our tracking filter won't pick up internally
forwarded requests until servlet2.4)
        response.sendRedirect(newURL);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEBUG com.acme.Translator.handleRequest() - URI: /SHOW/1/Mike.Curwen
(44348ms)
DEBUG com.acme.Translator.handleRequest() - URL:
http://www.myapp.com/SHOW/1/Mike.Curwen (44349ms)
DEBUG com.acme.Translator.handleRequest() - PATH: null (44350ms)
DEBUG com.acme.Translator.handleRequest() - pid 1 - 1 CACHED (44357ms)
DEBUG com.acme.Translator.handleRequest() - SHOW:: /SHOW/1/Mike.Curwen
translates to: foo?cid=1&pid=1&uid=1&src=browse&pgid=1 (44363ms)
DEBUG com.acme.Translator.handleRequest() - URI: /SHOW/1/foo (44367ms)
DEBUG com.acme.Translator.handleRequest() - URL:
http://www.myapp.com/SHOW/1/foo (44368ms)
DEBUG com.acme.Translator.handleRequest() - PATH: null (44368ms)
DEBUG com.acme.Translator.handleRequest() - SHOW:: /SHOW/1/foo
translates to: foo?cid=1&pid=1&uid=0&src=browse&pgid=1 (44373ms)
DEBUG com.acme.Translator.handleRequest() - URI: /SHOW/1/foo (44376ms)
DEBUG com.acme.Translator.handleRequest() - URL:
http://www.myapp.com/SHOW/1/foo (44377ms)
DEBUG com.acme.Translator.handleRequest() - PATH: null (44378ms)
DEBUG com.acme.Translator.handleRequest() - SHOW:: /SHOW/1/foo
translates to: foo?cid=1&pid=1&uid=0&src=browse&pgid=1 (44382ms)
DEBUG com.acme.Translator.handleRequest() - URI: /SHOW/1/foo (44386ms)
DEBUG com.acme.Translator.handleRequest() - URL:
http://www.myapp.com/SHOW/1/foo (44387ms)
DEBUG com.acme.Translator.handleRequest() - PATH: null (44388ms)
DEBUG com.acme.Translator.handleRequest() - SHOW:: /SHOW/1/foo
translates to: foo?cid=1&pid=1&uid=0&src=browse&pgid=1 (44392ms)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.
.
etc, etc, etc, until you kill Tomcat

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



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to