Meaningless Drivel is fun!*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes setStatus() 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 "setStatus()" Watch "setStatus()" New topic
Author

setStatus()

riohk kurn
Ranch Hand

Joined: Oct 19, 2002
Posts: 31
Can we use setStatus() plus <error-code> to replace sendError()?
Sam Tilley
Ranch Hand

Joined: Dec 05, 2001
Posts: 160
setStatus() does not trigger the container to generate an error page, it just sends the status code to teh browser, which is then displayed by the browser. So it should only be used for setting non-error status codes, eg SC_OK
I think <error-page> only works with sendError()


Sam Tilley SCJP, SCWCD
Vedhas Pitkar
Ranch Hand

Joined: Jan 27, 2001
Posts: 445
Hi ,
I think that <error-page> & sendError() are 2 different things.sendError() is for sending messages like SC_UNAUTHORIZED explicitly while if some error occurs in your application then the page in error-page is shown.
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5371
CMIW
<error-page> has associated exception OR error code.
I think if you are using sendError(), then it should display server's default error page for it rather than associated error page in web.xml.
I dont have tomcat here with me.. do try and tell us too


"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
Marcelo Sousa Ancelmo
Ranch Hand

Joined: Jan 17, 2002
Posts: 497

sendError trigger the container about the status code of the error, then if you have in your DD:

And in your jsp or servlet code:

If for any reason this code is executed, then will be served for the client the forbid.jsp page.
For 404, if you have inside the context of the web application any request for a resource that doesn't exist, you don't have to explicity call sendError(), the container just call the page mapped in the DD.
[ November 22, 2002: Message edited by: Marcelo Sousa Ancelmo ]

Marcelo Sousa Ancelmo - Brazil
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setStatus()
 
Similar Threads
question about using boolean to check a condition of an object?
setStatus and setError
setStatus() and sendError()
regarding setStatus()
explicitly sending http 200ok message from servlet