JSP and HTTP return code

I am new at developing jsp, and I am looking for a way to send an HTTP return code under a specific condition.for ex :if(data==ok){HTPP_return_code = 200;}else {HTPP_return_code = 500;}Is it possible ?
[278 byte] By [jeffffa] at [2007-10-3 0:00:39]
# 1
You could try casting the implicit response object to an HttpServletResponse object and using the setStatusCode method.
tolmanka at 2007-7-14 16:48:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Within your JSP you can use the sendError method on the response object.

e.g.

if (data == ok) {

response.sendError(HttpServletResponse.SC_OK);

} else {

response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);

}

See http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletResponse.html

for possible HTTP return code constants.

dapachecoa at 2007-7-14 16:48:02 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...