#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    2
    Rep Power
    0

    Tomcat URL/Context modification on ISAPI Redirect?


    Hey all,

    I'm running Tomcat 4.0.4 with IIS 5.0 and the ISAPI Redirect setup.

    I have a Web Application that HAS to be the root application on the Tomcat server, but I don't want all traffic to IIS redirected to that App.

    I'd like to use something to the effect of "http://localhost/testapp/" and have it redirect to the root application. The problems I am running into are:

    Paths in the Web App are coded during the installation of the App. Since it's the root App, and has to be the root app, the paths are built off of "http://localhost".

    Editing the uriworkers.properties file and setting "/testApp/*" to the default worker gives me a 404 error, because there is no app called "testApp" in Tomcat. Doing the servlet mapping within the web.xml generates the same error, because the path "http://localhost/testApp/" isn't valid within the paths that are coded into the app.

    What I need is a method for Tomcat to drop everything after the servername on receipt.

    So the user would type in "http://localhost/testApp/index.htm" but it would be received as "http://localhost/index.htm" by the Root application.

    Does this make sense?

    Thanks for any help!
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Ok, well, I typed this reply below, then I realized that if you've got hardcoded paths in your output files (jsp or html), you're up a creek without a paddle anyway. Even if you change the url so that it gets sent to Tomcat correctly, all the links on your pages are still going to point to the default site.

    ----------------------------------------------
    Here's my original reply:

    Well, it sounds like what you want is something similar to apache's mod_rewrite. Here's the only thing that I could find for IIS that would do that kind of thing for free: http://www.isapirewrite.com/

    (Of course, you could always install Apache. It's very free .)

    Basically, what you want to do is take any incoming url that matches a pattern (something like .*/testapp/.*), and rewrite it on the server to remove the /testapp/ part. The rewrite piece should be able to do hidden rewrites, which means the client is totally unaware that the url is changing.

    ----------------------------------------
    Another thing that might get you a little closer is to create a second context on your tomcat server that's mounted on /testApp but points to the same files as the context mounted on ROOT. You're still going to have the path problem, though.
    -james
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    2
    Rep Power
    0

    Thanks


    Thanks for the reply, Bricker.

    I think I stated my problem wrong.

    This shouldn't happen at the IIS part of the Process. The ISAPI_Redirect by the folks working the Jakarta project sits on the IIS Server. I can modify that so that it ONLY URL's with "/testApp" in them will be routed to Tomcat. I want the "/testApp/" portion stripped off the URL AFTER it reaches Tomcat. So something like this..

    User types: http://localhost/testApp/index.htm
    URL is passed to IIS
    ISDAPI_Redirect (located on the IIS server) filters the URL since it matches the specs in the uriworkers.properties file.
    Http request is passed to Tomcat
    Tomcat snags the request and strips the "/testApp/" out of the URL, then passes it to the Web App.
    Another key point would be that Tomcat or IIS would have to re-insert the "/testApp/" portion when it was sending the information/request/whatever BACK to the user so that it's transparent.

    ?

    It sounds like you took my post as saying I wanted IIS to do this - I don't, because if IIS did it, then the Jakarta ISAPI filter would throw ALL traffic to Tomcat (I think)

    Sorry if I'm misunderstanding, I'm by no means even close to a Tomcat Guru.

    Thanks for your help, Bricker!
  6. #4
  7. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    Here's a diagram of what would(should) happen with ISAPI_Rewrite:
    Code:
    IIS		sees: http://woot.com/testApp/index.jsp
    	|
    	|	sends: http://woot.com/testApp/index.jsp
    	|
    	v
    ISAPI_Rewrite	sees: http://woot.com/testApp/index.jsp
    	|
    	|	sends: http://woot.com/index.jsp
    	|
    	v
    ISAPI_Redirect	sees: http://woot.com/index.jsp
    	|
    	|	sends: http://woot.com/index.jsp
    	|
    	v
    Tomcat
    Responses go in reverse, meaning the client always sees the "/testApp/" in the url.

    The problem with this is that any links in the html that are returned aren't going to have "/testApp/" in them. You'll either need another IIS filter that handles the rewriting, or some sort of proxy that will rewrite the html.

    Another option is to find a content rewriting, reverse proxy, j2ee application that you can mount at /testApp on your tomcat install. I'm not aware of anything that works like that, though.

    The last option is to actually change the html generated by your application. Either using a search/and/replace tool to switch all the urls, or by reinstalling it at a different location.
    -james

IMN logo majestic logo threadwatch logo seochat tools logo