Fórum

Problem with response.sendRedirect()

thumbnail
Jitendra Rajput, modificado 12 Anos atrás.

Problem with response.sendRedirect()

Liferay Master Postagens: 875 Data de Entrada: 07/01/11 Postagens Recentes
Can any one guild me why i can not use both "response.setRenderParameter()" and "response.sendRedirect()" in same method ...?


response.setRenderParameter("tabs1", value);
response.sendRedirect();

Becz when ever i am putting both of this in same method i m getting below error...

Caused by: java.lang.IllegalStateException: Set render parameter has already been called


Thanks in advance...
Jitendra
thumbnail
Sagar A Vyas, modificado 12 Anos atrás.

RE: Problem with response.sendRedirect()

Liferay Master Postagens: 679 Data de Entrada: 17/04/09 Postagens Recentes
Jitendra Rajput:
Can any one guild me why i can not use both "response.setRenderParameter()" and "response.sendRedirect()" in same method ...?


response.setRenderParameter("tabs1", value);
response.sendRedirect();

Becz when ever i am putting both of this in same method i m getting below error...

Caused by: java.lang.IllegalStateException: Set render parameter has already been called


Thanks in advance...
Jitendra



Hi Jitendra,

Here is ans of your Question :

First of all lets interpret both statement.
Line 1 ) response.setRenderParameter("tabs1", tabOne); -> That means it will set one render param in response called "tabs" .
Line 2) sendRedirect(redirectURL) --> this will instantly redirect on given URL.

Now lets have look on your code sequence
response.setRenderParameter("tabs1", tabOne); that means you want to redirect on some jsp page having tabs1 value as "tabOne" ;
Now in second line you wrote response.sendRedirect(redirectURL); to redirect on some given URL .
Internally in sendRedirect(); it will check for given response whether it has renderParam or not ? if yes then it will throw "ERROR" as you got.

Now to verify above ans you can perform revers case as below
if you write this line 1st: response.sendRedirect(redirectURL);
and second line : response.setRenderParameter("tabs1", tabOne);
this will not throw error it will directly render to given URL..
cause second line never get execute emoticon

Hope it will full fill your ans emoticon

Thanks,
Sagar Vyas
thumbnail
Jitendra Rajput, modificado 12 Anos atrás.

RE: Problem with response.sendRedirect()

Liferay Master Postagens: 875 Data de Entrada: 07/01/11 Postagens Recentes
So is that any way by which i can avoid refresh problem and also able to set render parameter ?
thumbnail
Sagar A Vyas, modificado 12 Anos atrás.

RE: Problem with response.sendRedirect()

Liferay Master Postagens: 679 Data de Entrada: 17/04/09 Postagens Recentes
Jitendra Rajput:
So is that any way by which i can avoid refresh problem and also able to set render parameter ?



Hi Jitendra,

Please check my ans :

http://www.liferay.com/community/forums/-/message_boards/message/10349460


Thanks,
Sagar Vyas
thumbnail
Anindya Mallik, modificado 8 Anos atrás.

RE: Problem with response.sendRedirect()

Junior Member Postagens: 82 Data de Entrada: 15/01/13 Postagens Recentes
Can I do setRenderParameter after sendRedirect?

Like:
response.sendRedirect(authUrl);	
response.setRenderParameter("linkedInAuth", "linkedInAuth");


Please reply.
thumbnail
Sagar A Vyas, modificado 8 Anos atrás.

RE: Problem with response.sendRedirect()

Liferay Master Postagens: 679 Data de Entrada: 17/04/09 Postagens Recentes
Anindya Mallik:
Can I do setRenderParameter after sendRedirect?

Like:
response.sendRedirect(authUrl);	
response.setRenderParameter("linkedInAuth", "linkedInAuth");


Please reply.



Once you sendRedirect means you are asking server to start new request from browser with given URL - any line after sendRedirect will not work.

even though if you write response.setRenderParam.... line first, there is no any meaning of it as you are asking server to send new request by writing sendRedirect

Hope this make sense.

Thanks,
Sagar Vyas