aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Why there is no IllegalStateException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Why there is no IllegalStateException" Watch "Why there is no IllegalStateException" New topic
Author

Why there is no IllegalStateException

Siddarth Cherukumudi
Greenhorn

Joined: Aug 02, 2013
Posts: 29

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

With Best Regards,
Siddarth

OCPJP 6
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1715
    
  25

Did you read this thread?

Regards,
Frits
Siddarth Cherukumudi
Greenhorn

Joined: Aug 02, 2013
Posts: 29

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
Bartender

Joined: Apr 07, 2010
Posts: 1715
    
  25

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why there is no IllegalStateException