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.