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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Force All Requests to a single servlet
-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-namemyRedirectorServlet/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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Force All Requests to a single servlet
From: Jim Willeke [mailto:[EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Force All Requests to a single servlet
Tomcat 5.5 Ok, I deployed to: /tomcat9080/webapps/ROOT/WEB-INF web.xml welcome-file-list welcome-fileindex.jsp/welcome-file /welcome-file-list servlet servlet-nameRedirect/servlet-name servlet-classcom.willeke.web.Redirect/servlet-class /servlet servlet-mapping servlet-nameRedirect/servlet-name url-pattern/*/url-pattern /servlet-mapping /web-app Almost works. The only issue I have is when a URL like: http://willeke.com:9080/wikildap/Wiki.jsp?page=UsefullCommandsForEdirectory The redirect is to: http://ldapwiki.willeke.com/Wiki.jsp Which is close (and probably able to live with) but looks like I am loosing anything from ...Wiki.jsp? beyond. I am using the request.getRequestURL() method to get the the incoming URL. Do I need to do something different? thanks -jim - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Force All Requests to a single servlet
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Jim, Jim Willeke wrote: | Almost works. | | The only issue I have is when a URL like: | http://willeke.com:9080/wikildap/Wiki.jsp?page=UsefullCommandsForEdirectory | | The redirect is to: | http://ldapwiki.willeke.com/Wiki.jsp Sounds like you are not preserving the entire URL. | Which is close (and probably able to live with) but looks like I am | loosing anything from ...Wiki.jsp? beyond. | | I am using the request.getRequestURL() method to get the the incoming URL. | | Do I need to do something different? Yes. Read the javadoc for HttpServletRequest and you'll see methods to gather all of the information you need. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.8 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkftIToACgkQ9CaO5/Lv0PCMFgCeNdiNlFUZehwvrfH++K+qZr29 HPgAoIdygRcIwO0SgLIvdX6riEfINBtw =5MA0 -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]