掲示板

Problem with response.sendRedirect()

thumbnail
12年前 に Jitendra Rajput によって更新されました。

Problem with response.sendRedirect()

Liferay Master 投稿: 875 参加年月日: 11/01/07 最新の投稿
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
12年前 に Sagar A Vyas によって更新されました。

RE: Problem with response.sendRedirect()

Liferay Master 投稿: 679 参加年月日: 09/04/17 最新の投稿
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
12年前 に Jitendra Rajput によって更新されました。

RE: Problem with response.sendRedirect()

Liferay Master 投稿: 875 参加年月日: 11/01/07 最新の投稿
So is that any way by which i can avoid refresh problem and also able to set render parameter ?
thumbnail
12年前 に Sagar A Vyas によって更新されました。

RE: Problem with response.sendRedirect()

Liferay Master 投稿: 679 参加年月日: 09/04/17 最新の投稿
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
8年前 に Anindya Mallik によって更新されました。

RE: Problem with response.sendRedirect()

Junior Member 投稿: 82 参加年月日: 13/01/15 最新の投稿
Can I do setRenderParameter after sendRedirect?

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


Please reply.
thumbnail
8年前 に Sagar A Vyas によって更新されました。

RE: Problem with response.sendRedirect()

Liferay Master 投稿: 679 参加年月日: 09/04/17 最新の投稿
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