JSF: How to forward a request to another page in action?
Posted
by
Satya
on Stack Overflow
See other posts from Stack Overflow
or by Satya
Published on 2009-12-17T14:27:17Z
Indexed on
2010/12/26
12:54 UTC
Read the original article
Hit count: 194
I want to forward request to another page from action class I am using below code in my jsf action :
public String submitUserResponse(){
......
......
parseResponse(uri,request,response);
....
return "nextpage";
}
public String parseResponse(String uri,request,response){
if(uri != null){
RequestDispatcher dispatcher = request.getRequestDispatcher(uri);
dispatcher.forward(request, response);
return null;
}
.................
..................
return "xxxx";
}
"submitUserResponse" method is being called when user clicks the submit button from the jsp and this method returns "nextpage" string here request forwards to next page in normal flow. but in my requirement i will call "submitUserResponse () " which will execute and forwrd request to next page.It is going. but it is displaying some exceptions in server
That is :
java.lang.IllegalStateException: Cannot forward after response has been committed
Here my doubts are: 1.why next lines of code is being executed after forwarding my request using dispatched.forward(uri) . Same thing happening in response.sendRedirect("").
© Stack Overflow or respective owner