• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why there is no IllegalStateException

 
Ranch Hand
Posts: 37
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Again guys,
I am having a small doubt here, if you see the below code



the code must throw an IllegalStateException because I have sent the response, and i am trying to forward or include the resource, but it is showing me
a clean output, why is this happening?

can somebody please shed some light on this..


Thanks a lot in advance
 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you read this thread?

Regards,
Frits
 
Siddarth Cherukumudi
Ranch Hand
Posts: 37
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot Frits for the response,

Yes i have gone through the thread,


This is what i understood from the thread, please correct me if i am wrong

1. Once the response is committed, you cannot forward or redirect to any other page
2. Even though the response is committed you can add and modify the response headers and data, but you cannot redirect or forward

but i have a doubt regarding your quote below

Frits wrote:
Conclusion: the container handles a static HTML file different from a JSP file (although the generated java files of both JSPs look the same)



I did not understand what exactly you meant by that sentence

I did try the Sagar Shroff's code, but i was not getting any exception

Please explain me what is going on?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Siddarth Cherukumudi wrote:
1. Once the response is committed, you cannot forward or redirect to any other page
2. Even though the response is committed you can add and modify the response headers and data, but you cannot redirect or forward


Correct!

Siddarth Cherukumudi wrote:

Frits wrote:
Conclusion: the container handles a static HTML file different from a JSP file (although the generated java files of both JSPs look the same)


I did not understand what exactly you meant by that sentence


If you forward (using a RequestDispatcher) from a JSP to a static HTML file you will get an IllegalStateException
If you forward (using a RequestDispatcher) from a JSP to another JSP you won't get an IllegalStateException

Siddarth Cherukumudi wrote:I did try the Sagar Shroff's code, but i was not getting any exception
Please explain me what is going on?


Don't worry about that, application servers change over time. What is important are the two rules you extracted from that thread.

Regards,
Frits
reply
    Bookmark Topic Watch Topic
  • New Topic