Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why there is no IllegalStateException

 
Siddarth Cherukumudi
Greenhorn
Posts: 29
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2536
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read this thread?

Regards,
Frits
 
Siddarth Cherukumudi
Greenhorn
Posts: 29
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • 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
Saloon Keeper
Pie
Posts: 2536
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic