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

when exactly response is commited?

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


It shows an IllegalStateException on browser.
Why because response is commited before forwarding second time.

But where exactly response is commited???
I never called flush() method and the second way is if buffer automatically fills then it writes content to stream (sent information to client), but I don't think that buffer is filled here...

(And if stream is unbuffered then it would have given error at the first forward itself, but this is also not the case)


Thanks.
[ May 26, 2006: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think JSP compiler generates the code to commit the response at the end of service method. So when you forward for the second time, the forward method throws IllegalStateException since the response is committed.

We never do ourselves of commiting the response, it usually taken care by the container.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Dilip Kumar Jain:
I think JSP compiler generates the code to commit the response at the end of service method. So when you forward for the second time, the forward method throws IllegalStateException since the response is committed.

We never do ourselves of commiting the response, it usually taken care by the container.



If container generate 'response commiting code' just before the end of service() method then this code anyway will be executed after 'second time forward code'...
 
Manesh Kumar
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

before the end of service code


I meant for sevice() menthod second jsp file (b.jsp).

After forwarding for the first time to b.jsp (the response will be commited after this), The execution will resume in service method of a.jsp. The second call to forward method will throw an IllegalStateException , resulting halt in execution of service method in a.jsp.

I think this clears your doubt.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Dilip Kumar Jain:

I meant for sevice() menthod second jsp file (b.jsp).

After forwarding for the first time to b.jsp (the response will be commited after this), The execution will resume in service method of a.jsp. The second call to forward method will throw an IllegalStateException , resulting halt in execution of service method in a.jsp.

I think this clears your doubt.



Thanks Dilip.
Got it.

 
When people don’t understand what you are doing they call you crazy. But this tiny ad just doesn't care:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic