• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

IllegalStateException is coming if I use sendRedirect() method..

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

I am having a HTML page, which is devided as frames. There is 3 frames in this page named as first,left and content. In content frame I have a login page. Here when user clicks on login button, In content frame, some other jsp page should gets displayed(say the jsp page is welcome.jsp).

For this, Previously I have used



But the problem here is..If I login once..it is coming properly. If I click on some other button in another frame and logout..Now in case if I login again an error is coming like..

HTTP Status 500

description The server encountered an internal error() that prevented it from fulfilling this request.

exception

java.lang.IllegalStateException: Cannot forward after response has been committed.
...
...

As shown above the error is coming..So what I did means instead of using sendRedirect() method, I simply assigned the frame location to "/abc/welcome.jsp". Now it is working fine..But I just want to know what was the problem with sendRedirect() method. In which case, the above error will come?

Can anybody make me known..??

Thanks in Advance,
Shashi.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you want to use sendRedirect on response. response should not commit already
 
Shashi Kala
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

response should not commit already


means.. Can you explain in detailed..?
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

java.lang.IllegalStateException: Cannot forward after response has been committed.



The exception itself gives the reason.
And response has been committed means that you have already written the response to the client , so now you dont have control over it.
Please see this FAQ entry for more information.


Hope this helps
 
Shashi Kala
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks All..

I understood what is happening.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Shashi,

It'll be better if you use

<jsp:forward page ="("/abc/welcome.jsp"/>

in place of

response.sendRedirect("/abc/welcome.jsp");

after checking all the necessary conditions for the login stuff.
This tag doesn't notify the browser about the new page. The new page is opened but you need to notice that the address in the address bar remains the same.

Thank You,
Nishant
 
Nishant Kr
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<jsp:forward page ="/abc/welcome.jsp"/>
 
Amit Ghorpade
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nishant Kr welcome to Javaranch ,
If you want to edit a post(posted by you of course), then you can do it by simply clicking the icon.

Hope this helps
[ August 07, 2008: Message edited by: Amit Ghorpade ]
 
Nishant Kr
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mr Ghorpade,

Can you please answer to the topic...? If you don't have that much of ability or kind nature to help somebody, you better be in peace. I find most of your forums to be useless....!

Thank you
 
Amit Ghorpade
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nishant Kr
Can you please answer to the topic...?


Its already posted above by me.


If you don't have that much of ability or kind nature to help somebody, you better be in peace.


Do you have any good reason to say that? If yes please let me know.
But anyways I dont think you are supposed to tell what I should do.

I find most of your forums to be useless....!


I dont have any forum
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Nishant Kr", you have previously been warned on one or more occasions regarding adjusting your display name to meet JavaRanch standards. This is not optional. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it prior to your next post.

Your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Be aware that accounts with invalid display names are disabled.

bear
JavaRanch Sheriff
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic