This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JSP and the fly likes IllegalStateException  in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "IllegalStateException  in JSP " Watch "IllegalStateException  in JSP " New topic
Author

IllegalStateException in JSP

padma patil
Ranch Hand

Joined: Nov 06, 2001
Posts: 41
Hi,
I have
1)one jsp page say p1.jsp which has html form and 3 submit buttons.
2)on submit it goes to p2.jsp, which depending on button name redirect to
page p3.jsp ->button1
p4.jsp ->button2
p5.jsp ->button3
I am redirecting as,
if(button.equals(new String("button1")))
response.sendRedirect("http://localhost:8080/p2.jsp");
if(button.equals(new String("button2")))
response.sendRedirect("http://localhost:8080/p2.jsp");
if(button.equals(new String("button3")))
response.sendRedirect("http://localhost:8080/p3.jsp");

when I click on buttin1 on page p1.jsp , it throws IllegalStateException if I comment all the outstream statements and response.sendRedirect statements before and after the response.sendRedirect("http://localhost:8080/p2.jsp"); statement it doesn't throws IllegalStateException .
But I need have response.sendRedirect statements if button2 or button3 are clicked.
Is there was to handle this?
Another thing is if I use <jsp:forward ......> in all if statements it works fine but when I click the browser back button from p3.jsp it give me Page expired warning and I need to refresh the page to go back to p1.jsp . With the response.sendRedirect (" ") statement refresh problem is solved but
IllegalStateException rises!!!
I realy appreciate any help in this.
thakns,
padmashree
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
when I click on buttin1 on page p1.jsp , it throws IllegalStateException if I comment all the outstream statements and response.sendRedirect statements before and after the response.sendRedirect("http://localhost:8080/p2.jsp"); statement it doesn't throws IllegalStateException .

When using the sendRedirect(...) of the response, if the response is committed to the client, an IllegalStateException occurs.
You could try requestDipatcher.forward(...) method instead.
regds.
- madhav


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
Alternately you could specify a big buffer for the output so that it would not be flushed by the time you decide to redirect.
Bill
padma patil
Ranch Hand

Joined: Nov 06, 2001
Posts: 41
Hi All,
Appreciated your response. I solved the problem using sendRedirect() by removing all "out" statements before and after sendRedirect();
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IllegalStateException in JSP
 
Similar Threads
problem in running AWT programs!!
DispatchAction and html:cancel
Single Portlet Refresh in a Portal Page
Problem in response.sendredirect
Exception: wrong parent for CardLayout