Click to See Complete Forum and Search --> : How to use JSP to modify HTTP response status code?
George2
January 27th, 2003, 01:02 AM
Hi, everyone!
Normal HTTP response status code is like this,
--------
HTTP/1.1 200 OK
--------
I want to use JSP to modify the status code like this,
--------
HTTP/1.1 666 OK
--------
How to do the job?
Thanks in advance,
George
dlorde
January 27th, 2003, 04:36 AM
Use HttpServletResponse.sendError(...) (http://java.sun.com/j2ee/sdk_1.2.1/techdocs/api/javax/servlet/http/HttpServletResponse.html#sendError(int,%20java.lang.String)).
Debugging is more difficult than coding. If you are as clever as you can be when coding, how can you ever hope to debug the code?
George2
January 27th, 2003, 05:29 AM
Thanks, dlorde pal!
I have tried your method, it really works, but
still do not serve my purpose entirely.
I want to modify the HTTP response code
--------
HTTP/1.1 200 OK
--------
to
--------
HTTP/1.1 666 hehe
--------
I use sendError(666, "hehe"),
but "hehe" displays in the body and not in the header.
What I want to do is to send error code (666) and error
message ("hehe") through the first line of HTTP response
header.
How to do that job?
Thanks in advance,
George
dlorde
January 27th, 2003, 05:20 PM
I don't know, George, it's not something I've had to do. Why not try all the likely looking HttpServletResponse 'header' methods? I don't know any other way to set response header data.
Sometimes trial and error is the best way...
The key to personal success is initiative...
George2
January 27th, 2003, 09:12 PM
Thanks! Let me try!
BTW: If you have got the answer, please notify me!
:-)
Originally posted by dlorde
I don't know, George, it's not something I've had to do. Why not try all the likely looking HttpServletResponse 'header' methods? I don't know any other way to set response header data.
Sometimes trial and error is the best way...
The key to personal success is initiative...
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.