sendRedirect failed

Hi,

I am facing a problem redirecting to a particular url from the process view.

I call the sendRedirect method passing the url as parameter but it does not redirect to the specified url. I checked the logs and found no exception like illegalStateException or IOException.

The code looks like this.

getPortalPageContent().getResponse().sendRedirect(url);

return;

We are using IIS webserver and Weblogic Cluster.

Please help me.

[476 byte] By [venksrira] at [2007-10-3 4:41:36]
# 1
...And what would getPortalPageContent() be?Don't you have direct access to the HttpServletResponse object to call sendRedirect on it?
karma-9a at 2007-7-14 22:45:41 > top of Java-index,Java Essentials,Java Programming...
# 2
The getPortalPageContent().getResponse() gives HttpServletResponse.
venksrira at 2007-7-14 22:45:41 > top of Java-index,Java Essentials,Java Programming...
# 3
> The getPortalPageContent().getResponse() gives> HttpServletResponse.Perhaps. But it does look as if it is eating an IllegalStateException doesn't it?
cotton.ma at 2007-7-14 22:45:41 > top of Java-index,Java Essentials,Java Programming...
# 4
No there is no illegalStateException. I checked before the line whether the response is commited and it return False.But when the method sendRedirect is called, it failed to execute and the page stays in the same url
venksrira at 2007-7-14 22:45:41 > top of Java-index,Java Essentials,Java Programming...
# 5
Any configuration in the server level has to be done?
venksrira at 2007-7-14 22:45:41 > top of Java-index,Java Essentials,Java Programming...
# 6
> No there is no illegalStateException.I said eating.We'll never know unless we can see what that portlet thingy is doing. I would bet heavily though that it is already sending some content or other headers and that is in fact the issue here.
cotton.ma at 2007-7-14 22:45:41 > top of Java-index,Java Essentials,Java Programming...
# 7
please suggest me how to overcome this problem
venksrira at 2007-7-14 22:45:41 > top of Java-index,Java Essentials,Java Programming...
# 8
> please suggest me how to overcome this problemDon't use that portlet thingy?
cotton.ma at 2007-7-14 22:45:41 > top of Java-index,Java Essentials,Java Programming...
# 9

getPortalPageContent().getResponse() is giving the HttpServletResponse Object.

Just to brief what am i doing

This line of code is written in a ProcessView which extends GenericBeanView described below.

getPortalPageContent() is a method in the GenericBeanView class which extends PortlaBeanView interface and gives PortalPageContext object .

PortalBeanView : Each request that the server gets has a PortalPageContext object, which encapsulates references to the HTTPRequest, HTTPResponse, and other page-specific data.

I have written the code for redirection in a serviceHTML method which is an abstract method in the GenericBeanView and basically used for redirection only.

I checked whether the response is commited by the response object a line before calling the sendRedirect and retured false.

Just noticed it is redirecting in another stage with the same code.

Pour your thoughts on what probability the sendRedirect method fails with no exception too.

venksrira at 2007-7-14 22:45:41 > top of Java-index,Java Essentials,Java Programming...
# 10

As suggested in previous replies, obtain the HttpResponse object from the super class and call redirect() on it directly.

You can also install a browser plugin that allows you to examine the request/response headers. You can then check if your original response has a 'redirect' header. You can download such a plugin from [url http://livehttpheaders.mozdev.org/]here[/url]

ram.

Madathil_Prasada at 2007-7-14 22:45:41 > top of Java-index,Java Essentials,Java Programming...
# 11

> No there is no illegalStateException. I checked

> before the line whether the response is commited and

> it return False.

> But when the method sendRedirect is called, it failed

> to execute and the page stays in the same url

Assuming you do not have empty catch blocks eating the exception, did you try adding some extra log statements before/after the redirect call to ensure that:

1) the call to redirect gets executed to begin with, in case that block of code depends on some runtime conditions (if-else, etc..)

2) what the value of url is, if if it is a run-time value

You can also replace the call to redirect by sendError, and see if you get an err message. That will tell you if the resp obj that you get from the portal context is valid or not.

karma-9a at 2007-7-14 22:45:41 > top of Java-index,Java Essentials,Java Programming...