I was originally going to post this on StackOverflow but decided that it might be more appropriate here, apologies if I'm wrong. Also, I can only apologise that this question will be pretty low on useful information. I'm working on an installation of Tomcat 5.5.15, over which I have limited control. I'll describe the symptoms of my problem and hope the solution is obvious to someone who knows better than me. I've not found any useful solutions elsewhere online, but that's probably because I'm not searching for the right things...

The set up I'm working with is as follows (names changed to protect the innocent):

1 server ('jones')

This server has 3 instances of Tomcat running on it, let's call them 'andy', 'brian' and 'charlie'. Each instance has a set of the same web applications deployed (or, almost the same - they form different non-production environments for a bunch of tools).

I don't know much about 'andy' - I haven't really used that environment at all.

Everything works fine on 'brian'.

My problem is that, on 'charlie', whenever I encounter a redirect, my browser (same in IE, Firefox and Chrome) is redirected to 'brian:port', where port is the port for charlie, as specified in charlie's server.xml.

After that everything works fine, except that my session is gone, presumably because of the change when it redirected.

I'm not familiar enough with the Tomcat config to know where to look for more useful information - any pointers are very welcome. All I want is for redirect to come back as http://charlie/blah, rather than http://brian:port/blah.


Look for a <Host> block in charlie's server.xml.

What'd doing the redirecting? I'd be inclined to say to take a look at the web app; it may well have something hardcoded for the hostname somewhere instead of using the host that the request came in on.

  • Thanks very much Shane, that seems like a good pointer. For all three instances, my host element looks like (I hope this works as code...): <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> From the docs I'm guessing that I can change localhost to 'andy', 'brian' and 'charlie' as appopriate. I'm pretty confident that it's not the apps because (a) I can't see anything that looks like it's doing it, and (b) it happens for a standard Struts redirect, which I've never seen do the same thing before... – DaveyDaveDave Aug 19 '11 at 15:16
  • Hmm. I'm not sure it's had the effect I was looking for, I changed the <Host name="localhost"... to name="brian" on brian, and it still redirects to brian:port. I assume that means that the same will happen on charlie, but I can't play with that environment quite so easily... any other thoughts... at all..? – DaveyDaveDave Aug 19 '11 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.