tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Prevo <...@prevo.com>
Subject Re: relative redirect problem using port mapping vip
Date Fri, 08 Dec 2000 21:02:29 GMT
Technically you should never be relying on sending a relative redirect to 
begin with. The redirect method says that is should be an absolute URL. 
Here's the code we use in my project to overcome all of the redirect issues 
we ran into:

   protected String getServletUrl(HttpServletRequest req, String servletInfo)
   {
     StringBuffer url = new StringBuffer();

     String servletPath = req.getServletPath();
     int servletSlash = servletPath.lastIndexOf('/');

     url.append(req.getScheme());
     url.append("://");
     url.append(req.getHeader("Host"));
     if (servletSlash < 0)
       url.append('/');
     else
       url.append(servletPath.substring(0, servletSlash + 1));
     url.append(servletInfo);

     return url.toString();
   }

Hope this helps.
Joe

At 12/7/2000 03:10 PM, you wrote:
>Hi all
>
>we use tomcat as a web server on multiple processors having different IP
>addresses behind a VIP portal.  The VIP maps Ip adreeses and ports also
>(therefore a request send to port 80 can reach a processor with port 8080,
>etc.).
>
>When doing a relative redirect (response.sendRedirect method), the Absolute
>URL build from the relative URI does not seem to be produced properly.  It
>takes the host name from the request header but takes the port from the web
>server (from HttpRequestAdapter.getServerPort).  therefore creating a
>redirect url command with the right IP address but the wrong port (in our
>case 8080 i.o. 80).  That seems to be a bug in the tomcat code as it should
>take the port from the request header.  But can someone tell me if I might
>be doing something wrong before I change the code...?)
>
>Benoit Lalumiere
>Software Architect
>Jambala Innovation Cell
>Ericsson Canada (LMC)


Mime
View raw message