- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
public class SomeServlet extends HttpServlet {
//...
private static final int ERROR_NOT_FOUND = 404;
private static final int ERROR_INTERNAL = 503;
//...
protected void doPost(HttpServletRequest req, HttpSerletResponse resp) {
//...
if (buff != null) {
if (buff.length == 0) {
resp.sendError(ERROR_INTERNAL);
}
//...
} else {
resp.sendError(ERROR_NOT_FOUND);
}
}
}
http://download.oracle.com/javaee/6/api/javax/servlet/http/HttpServletResponse.html