Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Please answer these few doubts

 
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
 
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic