views:

618

answers:

3

When I do a redirect inside J2EE web application deployed on WebLogic it sends back to the client the following response:

HTTP/1.1 302 Moved Temporarily
Cache-Control: no-cache="set-cookie"
Date: Sat, 12 Dec 2009 07:37:43 GMT
Transfer-Encoding: chunked
Location: http://server:port/front/page
Set-Cookie: JSESSIONID=CDdjLjLHSLlGxzzBT7dmLCw7JFZyBTxp95gJyxSL8GLS2gpNGKpb!1582307085; path=/
X-Powered-By: Servlet/2.4 JSP/2.0

01d7
<html><head><title>302 Moved Temporarily</title></head>
<body bgcolor="#FFFFFF">
<p>This document you requested has moved temporarily.</p>
<p>It's now at <a href="http://server:port/front/page"&gt;http://server:port/front/page&lt;/a&gt;.&lt;/p&gt;
</body></html>

0000

Is there a way to override that HTML?

+1  A: 

Hi,

You can use the web.xml of your application to override it, like:

<error-page>
 <error-code>302</error-code>
 <location>/error302.jsp</location>
</error-page>

EDIT: The error page may start with:

<%@ page language="java" isErrorPage="true" %>
<%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
<html>
  <head>
...

Regards.

ATorras
Do you have an example of such JSP? That will insert the redirected URLs correctly?
Superfilin
Huh? An error page for a 302?
Pascal Thivent
@Pascal - and why not? Admittedly it won't normally be displayed in a typical web browser. But there are other use-cases for HTTP!
Stephen C
But is there a working example of such JSP?
Superfilin
@Atorras, but how would you get the URL that 302 response is redirecting to?
Superfilin
The HttpServletResponse object has a sendRedirect() method you could use to redirect the request (inside the error302.jsp or inside some controller). Example: response.sendRedirect("correctLocation.jsp")
ATorras
There is no big sense in that as it will be recursively hitting the same page :).
Superfilin
+1  A: 

I don't know from where this page comes but I'd like to see the response from WebLogic, especially the content of the Location in the header. Actually, I don't know Fiddler but I wonder if it is not breaking things here (see this similar question here on SO).

UPDATE: I think I finally start to understand the issue a bit more, thanks to the OP comment. Right now, I'm wondering if setting WLProxySSL to ON in the plugin configuration would help.

When WLProxySSL is set to ON, the location header returned to the client from WebLogic Server specifies the HTTPS protocol.

I'll dig this more and update this answer later.

Pascal Thivent
The problem is not in Fiddler and it's actually just a proxy/debug tool. I just used Fiddler to understand the problem. Browser handles redirect correctly, but the problem actually is in the absolute URL that is contained in 302 response. We placed an Apache server before WebLogic to force HTTPS. We use relative URLs wherever possible in our application and that does not cause any problems for HTTPS server, except when redirect is done, because of the use of absolute URL that is HTTP. I will attach the raw response to the answer.
Superfilin
Ahhhh, I think I finally start to understand the issue. Everything is still not clear but it's better. Actually, I feel like this now: why the hell don't you provide these details in the initial question?!? :)
Pascal Thivent
:) I thought that just replacing the standard 302 response would be a better solution.
Superfilin
I have updated the question with full HTTP response.
Superfilin
A: 

My initial problem was related to absolute URLs in the 302 response. And I have found that absolute URL is dictated by HTTP specification. Even though most browsers tolerate relative URLs, that's not a reliable solution anyway. That means that overriding 302 response will not give me the desired result in all possible situations. I would rather use the solution proposed by Pascal or make Apache additional configuration for URL rewrite engine.

Superfilin