1 28 29 package com.caucho.servlets; 30 31 import javax.servlet.GenericServlet ; 32 import javax.servlet.ServletException ; 33 import javax.servlet.ServletRequest ; 34 import javax.servlet.ServletResponse ; 35 import javax.servlet.http.HttpServletResponse ; 36 import java.io.IOException ; 37 38 55 public class ErrorStatusServlet extends GenericServlet { 56 private int _statusCode = 404; 57 private String _message; 58 59 62 public void setStatusCode(int code) 63 { 64 _statusCode = code; 65 } 66 67 70 public void setMessage(String message) 71 { 72 _message = message; 73 } 74 75 public void service(ServletRequest request, ServletResponse response) 76 throws ServletException , IOException 77 { 78 HttpServletResponse res = (HttpServletResponse ) response; 79 80 if (_message != null) 81 res.sendError(_statusCode, _message); 82 else 83 res.sendError(_statusCode); 84 } 85 } 86 | Popular Tags |