You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jim Willeke <jw...@gmail.com> on 2008/03/28 14:51:13 UTC
Force All Requests to a single servlet
I have moved a sever from port 9080 to using another tomcat instance
(on port 80) and have renamed the sites.
I want to intercept all the requests to the 9080 port and analyze the
incoming URL and redirect to the new location(s).
I can write the servlet, but have not figured out how to force every
incoming request to use the servlet.
I never want a request to get a "Not found error"
Thanks -jim
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Force All Requests to a single servlet
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Jim Willeke [mailto:jwilleke@gmail.com]
> Subject: Force All Requests to a single servlet
>
> I want to intercept all the requests to the 9080 port and analyze the
> incoming URL and redirect to the new location(s).
You didn't bother to tell us what version of Tomcat you're using, so the
links below are for the current one; adjust as needed.
You might want to consider a Valve rather than a servlet, since you can
configure a valve at the <Engine> level. One of Tomcat's built-in
valves could be a starting point:
http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html
The related API doc is here:
http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/catalina/valves/p
ackage-summary.html
- 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 start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Force All Requests to a single servlet
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Jim,
Jim Willeke wrote:
| I have moved a sever from port 9080 to using another tomcat instance
| (on port 80) and have renamed the sites.
|
| I want to intercept all the requests to the 9080 port and analyze the
| incoming URL and redirect to the new location(s).
You may have simpler alternatives:
1. Use your OS to forward port 9080 to port 80.
2. Run a second <Connector> on port 9080 on the same server.
~ No other configuration should be necessary.
3. If you are running a web server in front of Tomcat:
~ a. Use RedirectPermanent (the browser will do your work for you)
~ b. Listen on 9080 and use the same mappings to Tomcat
~ c. Use mod_rewrite or mod_proxy to proxy the traffic between ports
Also, when you say "redirect", do you really mean to respond to the
request with an HTTP 3xx response? Or, do you mean "make it go to the
right place"?
| I can write the servlet, but have not figured out how to force every
| incoming request to use the servlet.
| I never want a request to get a "Not found error"
If this is what you really want to do, you can always just map
everything to your one servlet:
<servlet-mapping>
~ <servlet-name>myRedirectorServlet</servlet-name>
~ <url-pattern>/*</url-pattern>
</servlet-mapping>
Note that you'll have to deploy this as the ROOT application if you want
to catch /everything/.
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkfs/uIACgkQ9CaO5/Lv0PAz5ACfTCxXIkkbl0UpNGfUM/TCnTp6
Y28AmQEa7DQ4iOLkBoql5MYKOECk191i
=pUpt
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org