• 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
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Please answer these few doubts

 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please just explain me what happens :-
1)after sendError() has been executed and we write to the response.
there is ambiguity in answers given in JWEBPLUS and Study Kit.
2)after forward() has been executed and we write to the response.

3)it is mentioned in Study kit book that setStatus() method does not trigger the error page machinery and just sends the status code directly to the browser, but it is triggering ....
the error page mapped in web.xml for that status code is being displayed.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you call setStatus (it doesn't matter if it's an error or non-error status code), the servlet is still responsible for providing the body of the response to the client.
Now, if the status code is, say, 404, and you'd mapped this to an error page in the deployment descriptor, then this probably explains why your error page is being displayed.
 
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IllegalStateException will be thrown if continue to write to reponse
after sendError(), sendRedirect(), forward() has being called.
setStatus() will be ignored after the response has been committed.
[ September 23, 2003: Message edited by: chi Lin ]
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi chi

IllegalStateException will be thrown if continue to write to reponse
after sendError(), sendRedirect(), forward() has being called.


When I tried with Tomcat, it DID NOT throw any IllegalStateException if we continue to write to response after sendError(), sendRedirect(), forward() has being called.
 
chi Lin
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Neeraj,
what I meant to say is :
sendError(), sendRedirect(), forward() will throw IllegalStateException if called after response is committed.
regards
 
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic