This is a a known issue with WebSphere...

Servlet 2.2 is unclear about sendRedirects with relative paths, servlet 2.3
clears it up.  WebSphere will change its implementation to match servlet 2.3
with the upcoming 5.0 release.

In the meantime, if you have WebSphere 4.0.2 or above, you can change its
behaviour to match the servlet 2.3 implementation by setting this JVM
property:

com.ibm.websphere.sendredirect.compliance=1

This will make WebSphere compliant with Servlet 2.3.  In my own testing this
solves most, if not all, of the incompatibility problems with sendRedirect.
 
Jeff Butler
CIBER, Inc.
St. Louis

-----Original Message-----
From: Nicolas De Loof
To: Struts Users Mailing List
Cc: Struts Developers List
Sent: 5/30/02 2:47 AM
Subject: response.sendRedirect on WebSphere

As conclusion on my "redirect" troubles :

I've made some test on WAS to understand the behaviour of it's
response.sendRedirect implementation.

If path used begins with "/", WAS builds an absolute URL considering
root as
WEBAPP CONTEXT (and not Servlet container root as servlet API defines
the
behaviour).

So, on WAS, Struts does not require to add context to the redirected URL
when using a "redirect=true" forward. If you use an absolute URL as path
(with protocol://server:port ...) WAS uses it.

To use Struts redirect option on WAS, you just have to comment this two
lines in an dedicated Servlet (that extens ActionServlet) :
// if (path.startsWith("/"))
//     path = request.getContextPath() + path;

If you don't want to have a WAS specific servlet, you can use this code
in
an extended ActionServlet (Struts 1.0.2) or RequestProcessor (Struts
1.1) :

if (path.startsWith('/')) {
    // build a absolute URL to the path
    path = request.getScheme() + "://"
            + request.getServerName()
            + ":" + request.getServerPort()
            + request.getContextPath()
            + path
}
response.sendRedirect(response.encodeRedirectURL(path));


Nico


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

Reply via email to