Package net.i2p.servlet
Class ErrorServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- net.i2p.servlet.ErrorServlet
-
- All Implemented Interfaces:
Serializable
,Servlet
,ServletConfig
public class ErrorServlet extends HttpServlet
Common servlet for errors This is intended for webapps and local plugins. It is not appropriate for eepsites or remotely-accessible plugins, as it uses local console resources. See http://www.eclipse.org/jetty/documentation/current/custom-error-pages.html for how to add to web.xml or see examples in bundled webapps. Init parameters:- CSSPath - absolue URL of CSS to reference, starting with /, defaults to console theme
- name - webapp or plugin name, will be translated with bundle, e.g. SusiMail
- bundle - package of translation bundle, e.g. net.i2p.susimail.web.messages
- Since:
- 0.9.34 adapted from routerconsole error.jsp, error500.jsp, and CSSHelper
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ErrorServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
_t(String s)
translate a string, console bundleprotected String
_t(String s, Object o)
translate a string, console bundleprotected String
_t(String s, Object o, Object o2)
translate a string, console bundleprotected String
_w(String s)
translate a string, with webapp bundleprotected void
doGet(HttpServletRequest req, HttpServletResponse resp)
protected void
doPost(HttpServletRequest req, HttpServletResponse resp)
Needed if the errored page was a POSTvoid
init()
protected void
outputMessage(PrintWriter out, int errorCode, String errorMsg, String errorURI, Throwable errorCause)
Override for specific cases.-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
-
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
-
-
-
Method Detail
-
init
public void init() throws ServletException
- Overrides:
init
in classGenericServlet
- Throws:
ServletException
-
doGet
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
- Overrides:
doGet
in classHttpServlet
- Throws:
ServletException
IOException
-
doPost
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
Needed if the errored page was a POST- Overrides:
doPost
in classHttpServlet
- Throws:
ServletException
IOException
- Since:
- 0.9.35
-
outputMessage
protected void outputMessage(PrintWriter out, int errorCode, String errorMsg, String errorURI, Throwable errorCause)
Override for specific cases. This supports 403, 404, and 500+. Output HTML that goes inside the div.- Parameters:
errorCode
- e.g. 404errorMsg
- non-null, may be empty, already HTML-escapederrorURI
- non-null, may be empty, already HTML-escapederrorCause
- may be null
-
-