Tomcat 5.5 URL redirect

Posted on 2007-10-19
Last Modified: 2013-12-02
Hi, I need help with Tomcat 5.5. Here is the situation I have a servlet application with url http://serverip:8080/name.

How i can make a tomcat to redirect all request sent to go to http://serverip:8080/appname

My backup plan is to use IIS to do the redirect to tomcat, but i am sure that there is much easier way.

Tnak you
Question by:amnhtech
    LVL 92

    Expert Comment

    tomcat would need to be listeneing on port 80 to be able to do that (and if it was you probably wouldn't need to redirect).
    so it sounds like u need to handle it externally to tomcat
    LVL 2

    Author Comment

    It looks like Tomcat is a scale down version of Apache. Its definitely doable, but I am not a java guy. My way around for now is running IIS on the same box to redirect all the requests. Probably there is a much better solution and will continue looking for it. Leaving the url as it is, is not an option for me.  
    Thank you
    LVL 92

    Accepted Solution

    tomcat isn't really a scaled down apache.
    how do u expect tomcat to redirect if its not even listeneing on that port?
    Why is your app on port 8080 if you want it to be acessible on port 80?
    LVL 13

    Assisted Solution

    If you set Tomcat to listen to port 80, then the servlet works on port 80 automatically. To do this edit server.xml and replace 8080 with 80.

    If you need to do a rewrite, I recommend installing Apache HTTPD and handle it there, using mod_rewrite and mod_proxy.
    LVL 2

    Author Comment

    Because is a scale down version of apache httpd.conf is missing. I have only some xml files. In addition to the port I have some other stuff behind it.

    Assisted Solution

    1) As mentioned above, run tomcat on port 80.

    In CATALINA_HOME/conf/servers.xml, here is the configuration:
      <Service name="Catalina">   <---- Inside this Service tag...
        <Connector port="80"     <---- This is what you need to change

    2) Also, as mentioned above, make sure that points to the machine on which tomcat is running.

    3) Have the context in CATALINA_HOME/conf/servers.xml point to your web-app using a virtual host. Put this in the same service as #1:

          <Host name="" appBase="PATH_TO_YOUR_WEBAPP">
            <Context path="" docBase="."/>
    LVL 2

    Author Comment

    i'll try it. Thanks

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    The viewer will learn how to implement Singleton Design Pattern in Java.
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now