• Post Reply Bookmark Topic Watch Topic
  • New Topic

HttpServletResponse Status  RSS feed

 
Surya Bahadur
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
The Java API provides the methods to set the status on the HttpServletResponse object.
res.setStatus(res.SC_NOT_FOUND)
res.sendError(res.SC_NOT_FOUND)
But my question is how do i get the status which i have set in some part of the code in the later sections of the code.
Say if the status is set based on some condition using an if statement like
if(something){
res.setStatus(res.SC_NOT_FOUND)
}else{
res.setStatus(res.SC_CONTINUE)
}
Say based on the status code from the response object the program behaviour changes
how to get the status which was set in the earlier part of the program because JavaAPI doesn't seem to provide a method to get the status.Please let me know how to do this....
Surya
 
Bosun Bello
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't you just declare avariable that will hold the status? Status us set as part of the response Header. You just have to save ti somewhere for leter retrieval.
 
Surya Bahadur
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bosun
Its not my program which is setting the status code,say my program just calls the method on some object which sets this status and there is no Get method provided on that object to get the status.The only way for me is to use the Response object,then how do i get the status.
Surya
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!