jk connector and response.sendRedirect()
I'm pulling my hair out on this one, but I think I've narrowed it down so I can at least ask the question... We're running Tomcat 4.1.24/Apache 1.3.27/Sun JDK 1.4.2 using mod_jk. The issue we're dealing with now, is that in some cases an existing webapp uses the response.sendRedirect() method to redirect the client to another relative URL. Previously, we were using the warp connector and everything worked fine. Now, using mod_jk, the redirect fails causing the browser to say it can't find the host. Here's what I've tried so far. I removed Apache from the mix and setup the Coyote HTTP/1.1 connector to listen to port 80. Everything works fine with this setup, so it must be a connector thing, right? With just the JK connector enabled and listening on 8009, I've added Apache back and setup Alias elements in the Host element of my server.xml. The host the browser says it can't find is the actual hostname of the machine, not the DNS entry. I believe this is a problem unique to the jk connector (or how I have it configured) and the response.sendRedirect() method. Here's the documentation from the servlet API: public void sendRedirect(java.lang.String location) throws java.io.IOException Sends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container will convert the relative URL to an absolute URL before sending the response to the client. If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to. Here's the connector and Host element stuff from my server.xml: ... Connector className=org.apache.ajp.tomcat4.Ajp13Connector port=8009 minProcessors=5 maxProcessors=75 enableLookups=true acceptCount=10 debug=0 connectionTimeout=0 useURIValidationHack=false/ ... Host name=localhost debug=0 appBase=webapps unpackWARs=true autoDeploy=true Aliasdemo.mycompany.com/Alias Aliasgoatweed/Alias Aliasdemo/Alias Aliasgoatweed.mycompany.com/Alias Aliasdemo.anotherdomain.net/Alias Aliasgoatweed.anotherdomain.net/Alias ... /Host Anyone have any ideas or see a glaring mistake on my part? I'll gladly provide more info if needed. Thanks, Chris Egolf - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jk connector and response.sendRedirect()
Chris Egolf wrote: With just the JK connector enabled and listening on 8009, I've added Apache back and setup Alias elements in the Host element of my server.xml. The host the browser says it can't find is the actual hostname of the machine, not the DNS entry. Can Apache resolve this hostname? Is it setup in /etc/hosts (or the HOSTS file if you're using Win32)? John - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: jk connector and response.sendRedirect()
I'm not a programmer but an administrator. We have had an similar problem and solved it by changing the apache option UseCanonicalNames from on to off. [when UseCanonicalName ist on, everytimes you call response.sendRedirect() the apache takes the servername (from httd.conf) and make the absolute URL. If you are switching UseCanonicalNames to off, apache takes the hostname from the incoming HTTP-Header] Maybe this tip helps Regards :o) Ilona -Ursprüngliche Nachricht- Von: Chris Egolf [mailto:[EMAIL PROTECTED] Gesendet: Mittwoch, 30. Juli 2003 16:18 An: [EMAIL PROTECTED] Betreff: jk connector and response.sendRedirect() I'm pulling my hair out on this one, but I think I've narrowed it down so I can at least ask the question... We're running Tomcat 4.1.24/Apache 1.3.27/Sun JDK 1.4.2 using mod_jk. The issue we're dealing with now, is that in some cases an existing webapp uses the response.sendRedirect() method to redirect the client to another relative URL. Previously, we were using the warp connector and everything worked fine. Now, using mod_jk, the redirect fails causing the browser to say it can't find the host. Here's what I've tried so far. I removed Apache from the mix and setup the Coyote HTTP/1.1 connector to listen to port 80. Everything works fine with this setup, so it must be a connector thing, right? With just the JK connector enabled and listening on 8009, I've added Apache back and setup Alias elements in the Host element of my server.xml. The host the browser says it can't find is the actual hostname of the machine, not the DNS entry. I believe this is a problem unique to the jk connector (or how I have it configured) and the response.sendRedirect() method. Here's the documentation from the servlet API: public void sendRedirect(java.lang.String location) throws java.io.IOException Sends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container will convert the relative URL to an absolute URL before sending the response to the client. If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to. Here's the connector and Host element stuff from my server.xml: ... Connector className=org.apache.ajp.tomcat4.Ajp13Connector port=8009 minProcessors=5 maxProcessors=75 enableLookups=true acceptCount=10 debug=0 connectionTimeout=0 useURIValidationHack=false/ ... Host name=localhost debug=0 appBase=webapps unpackWARs=true autoDeploy=true Aliasdemo.mycompany.com/Alias Aliasgoatweed/Alias Aliasdemo/Alias Aliasgoatweed.mycompany.com/Alias Aliasdemo.anotherdomain.net/Alias Aliasgoatweed.anotherdomain.net/Alias ... /Host Anyone have any ideas or see a glaring mistake on my part? I'll gladly provide more info if needed. Thanks, Chris Egolf - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jk connector and response.sendRedirect()
John Turner wrote: Chris Egolf wrote: With just the JK connector enabled and listening on 8009, I've added Apache back and setup Alias elements in the Host element of my server.xml. The host the browser says it can't find is the actual hostname of the machine, not the DNS entry. Can Apache resolve this hostname? Is it setup in /etc/hosts (or the HOSTS file if you're using Win32)? Yes, I believe so. I added all the possible hostnames as alias to /etc/hosts (BTW, I'm running on Linux -- RH7.3). Chris -- - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jk connector and response.sendRedirect()
Chris Egolf wrote: John Turner wrote: Can Apache resolve this hostname? Is it setup in /etc/hosts (or the HOSTS file if you're using Win32)? Yes, I believe so. I added all the possible hostnames as alias to /etc/hosts (BTW, I'm running on Linux -- RH7.3). Hmmm...my JkMount stuff is in the VirtualHost _default_:* sectionand the ServerName directive is the hostname the sendRedirect is failing on. -- Chris Egolf http://www.ugholf.net [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jk connector and response.sendRedirect()
When I use response.sendRedirect(), although redirecting to within the same context, I tend supply the whole URL. I thus avoid the kind of problems you seem to be getting. In a controller servlet where I redirect depending on the request, I do this: String urlPath = request.getScheme() + :// + request.getServerName() + : + request.getServerPort() + request.getContextPath(); I can then do this: response.sendRedirect(urlPath + /afolder/afile.jsp); Zach. Chris Egolf wrote: I'm pulling my hair out on this one, but I think I've narrowed it down so I can at least ask the question... We're running Tomcat 4.1.24/Apache 1.3.27/Sun JDK 1.4.2 using mod_jk. The issue we're dealing with now, is that in some cases an existing webapp uses the response.sendRedirect() method to redirect the client to another relative URL. Previously, we were using the warp connector and everything worked fine. Now, using mod_jk, the redirect fails causing the browser to say it can't find the host. Here's what I've tried so far. I removed Apache from the mix and setup the Coyote HTTP/1.1 connector to listen to port 80. Everything works fine with this setup, so it must be a connector thing, right? With just the JK connector enabled and listening on 8009, I've added Apache back and setup Alias elements in the Host element of my server.xml. The host the browser says it can't find is the actual hostname of the machine, not the DNS entry. I believe this is a problem unique to the jk connector (or how I have it configured) and the response.sendRedirect() method. Here's the documentation from the servlet API: public void sendRedirect(java.lang.String location) throws java.io.IOException Sends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container will convert the relative URL to an absolute URL before sending the response to the client. If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to. Here's the connector and Host element stuff from my server.xml: ... Connector className=org.apache.ajp.tomcat4.Ajp13Connector port=8009 minProcessors=5 maxProcessors=75 enableLookups=true acceptCount=10 debug=0 connectionTimeout=0 useURIValidationHack=false/ ... Host name=localhost debug=0 appBase=webapps unpackWARs=true autoDeploy=true Aliasdemo.mycompany.com/Alias Aliasgoatweed/Alias Aliasdemo/Alias Aliasgoatweed.mycompany.com/Alias Aliasdemo.anotherdomain.net/Alias Aliasgoatweed.anotherdomain.net/Alias ... /Host Anyone have any ideas or see a glaring mistake on my part? I'll gladly provide more info if needed. Thanks, Chris Egolf - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jk connector and response.sendRedirect()
I'm not a programmer but an administrator. We have had an similar problem and solved it by changing the apache option UseCanonicalNames from on to off. [when UseCanonicalName ist on, everytimes you call response.sendRedirect() the apache takes the servername (from httd.conf) and make the absolute URL. If you are switching UseCanonicalNames to off, apache takes the hostname from the incoming HTTP-Header] Maybe this tip helps Regards :o) Ilona Ilona, etc. - I didn't try the UseCanonicalName option yet, but I was able to resolve this issue by specifying a VirtualHost for each possible hostname in httpd.conf. I'm glad you mentioned how response.sendRedirect() works because that's exactly the behavior I was seeing. I think it's basically doing the same thing, although getting the hostname from the incoming HTTP-Header sounds like it would be more robust. As follow up, this is what finally fixed it in httpd.conf: NameVirtualHost * VirtualHost * ServerName host.mycompany.com /VirtualHost VirtualHost * ServerName host.someotherdomain.net /VirtualHost - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]