You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by jo...@thomsonreuters.com on 2010/07/21 17:13:27 UTC

How to map web app with different root paths?

Our application has a Context Root of "DealsWeb". I need to be able to
map a different root path to this web application. For example:

 

This: 

http://server.com/NASApp/DealSearch/DoSomethingServlet
<http://server.com/NASApp/DealSearch/DoSomethingServlet> 

 

Needs to map to this:

http://server.com/DealsWeb/DoSomethingServlet
<http://server.com/DealsWeb/DoSomethingServlet> 

 

I know how to use path mappings in one application but not across.

 

Thank you.

 

John


RE: How to map web app with different root paths?

Posted by jo...@thomsonreuters.com.
Should be posted for sure in a FAQ.

Thanks all for the links. I think that should cover it. 

-----Original Message-----
From: André Warnier [mailto:aw@ice-sa.com] 
Sent: Wednesday, July 21, 2010 3:04 PM
To: Tomcat Users List
Subject: Re: How to map web app with different root paths?

Apart from the answers already provided by Chuck and Christopher, I wonder if a FAQ about "proxying", "URL abstraction", "forwarding", "redirecting" etc.. and their differences would not be useful ?
This kind of question seems to come so often that it would save time in the end if there was just a link to point to.

Quick and dirty :

- a "redirect" is when the server sends a HTTP response to the browser saying "sorry, the URL you requested is wrong, but the right one is *here* (with the correct URL).
The browser then (without even informing the user) immediately makes a new request to this new URL.
Hint : the browser's URL bar, in that case, will show the new URL.
Advantage : the browser will also discard the old URL from its cache and history, and cache the new one instead.  The user may even notice, and request the correct URL right away the next time.
Inconvenient : there is more traffic, because there is one request/response exchange for nothing (original request -> 302 response from server -> new request from browser -> server response to "correct" request)

- a "forward" (and also the concept of "URL abstraction") is when the server silently rewrites the URL requested by the user, so that it will be processed by a different webapp (or return a different static document) than the one that would appear to be implied by the original request URL.
Hint : none, because the browser will think that the response comes for his original request URL.
Advantage : there is no extra network traffic, and it is faster (at least for the client), because it all remains internal to the server.
Inconvenient : the browser (and user) remain "stupid", in the sense that they will continue to use the original URL, thinking it is correct.
(This may actually not be an inconvenient, if this is what the server admin wants)

- a "proxy" is when the server receives a request for a URL which appears "local", but then silently behind the scene calls another server to provide the response.
The original server then reads the response from the background server and returns it to the client as if it had made it up himself.
Advantages/Inconvenients : a bit vast to discuss here, but this is the basic mechanism for something like load-balancing : a front-end server (with a single access point for the
clients) receives all requests, and intelligently distributes them to a number of background servers, in function of the load, the type of request, or whatever.
The client keeps thinking that the responses come from the front-end server, so it keeps talking to the front-end.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org



Re: How to map web app with different root paths?

Posted by André Warnier <aw...@ice-sa.com>.
Apart from the answers already provided by Chuck and Christopher, I wonder if a FAQ about 
"proxying", "URL abstraction", "forwarding", "redirecting" etc.. and their differences 
would not be useful ?
This kind of question seems to come so often that it would save time in the end if there 
was just a link to point to.

Quick and dirty :

- a "redirect" is when the server sends a HTTP response to the browser saying "sorry, the 
URL you requested is wrong, but the right one is *here* (with the correct URL).
The browser then (without even informing the user) immediately makes a new request to this 
new URL.
Hint : the browser's URL bar, in that case, will show the new URL.
Advantage : the browser will also discard the old URL from its cache and history, and 
cache the new one instead.  The user may even notice, and request the correct URL right 
away the next time.
Inconvenient : there is more traffic, because there is one request/response exchange for 
nothing (original request -> 302 response from server -> new request from browser -> 
server response to "correct" request)

- a "forward" (and also the concept of "URL abstraction") is when the server silently 
rewrites the URL requested by the user, so that it will be processed by a different webapp 
(or return a different static document) than the one that would appear to be implied by 
the original request URL.
Hint : none, because the browser will think that the response comes for his original 
request URL.
Advantage : there is no extra network traffic, and it is faster (at least for the client), 
because it all remains internal to the server.
Inconvenient : the browser (and user) remain "stupid", in the sense that they will 
continue to use the original URL, thinking it is correct.
(This may actually not be an inconvenient, if this is what the server admin wants)

- a "proxy" is when the server receives a request for a URL which appears "local", but 
then silently behind the scene calls another server to provide the response.
The original server then reads the response from the background server and returns it to 
the client as if it had made it up himself.
Advantages/Inconvenients : a bit vast to discuss here, but this is the basic mechanism for 
something like load-balancing : a front-end server (with a single access point for the 
clients) receives all requests, and intelligently distributes them to a number of 
background servers, in function of the load, the type of request, or whatever.
The client keeps thinking that the responses come from the front-end server, so it keeps 
talking to the front-end.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: How to map web app with different root paths?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John,

(Let's try this again.)

On 7/21/2010 11:13 AM, john.ranaudo@thomsonreuters.com wrote:
> > Our application has a Context Root of "DealsWeb". I need to be able to
> > map a different root path to this web application.
I feel like we just covered this in the last 24 hours or so. I can't
seem to find the thread, though.

> > For example:
> >
> > This:
> >
> > http://server.com/NASApp/DealSearch/DoSomethingServlet
> >
> > Needs to map to this:
> >
> > http://server.com/DealsWeb/DoSomethingServlet
> >
> > I know how to use path mappings in one application but not across.
How do you do it in a single application? If you use <servlet-mapping>,
then you're right: you can't map across webapps.

You can set up a fictional context, say, NASApp, that contains nothing
but redirects to the real app. You can use
http://www.tuckey.org/urlrewrite/ to map URL spaces from one to another.

Maybe something like this:

<rule>
  <from>/DealSearch/(.*)</from>
  <to type="redirect">/DealsWeb/$1</to>
</rule>

Note that the "NASApp" isn't mentioned because it's the context name. If
you have multiple contexts to map in this way, you could set up one
webapp/context for each of them, as above, or you could deploy a ROOT
webapp that intercepts them all. In that case, you'd need:

<rule>
  <from>/NASApp/DealSearch/(.*)</from>
  <to type="redirect">/DealsWeb/$1</to>
</rule>
<rule>
  <from>/SomeOtherName/DealSearch/(.*)</from>
  <to type="redirect">/DealsWeb/$1</to>
</rule>

etc.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxHPQ8ACgkQ9CaO5/Lv0PAUPwCgtZ17sNvrNvucm/sSGZg1exhj
rm4AoJVFu5qIvgy8kHaLwpYRzW+PiywT
=Q/kD
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: How to map web app with different root paths?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: john.ranaudo@thomsonreuters.com
> [mailto:john.ranaudo@thomsonreuters.com]
> Subject: How to map web app with different root paths?
> 
> This:
> http://server.com/NASApp/DealSearch/DoSomethingServlet
> <http://server.com/NASApp/DealSearch/DoSomethingServlet>
> 
> Needs to map to this:
> http://server.com/DealsWeb/DoSomethingServlet
> <http://server.com/DealsWeb/DoSomethingServlet>

Use the URL rewrite filter under either a dummy NASApp webapp or the ROOT webapp to forward or redirect the request to the desired URL.

http://www.tuckey.org/urlrewrite/

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org