This small servlet lets you protect access to some parts of your server. Servlet simply returns to the user error code and message provided as initial parameters for this servlet. By default servlet simply returns error code 404. How to use it: a) download errorMessagePackage.jar and save it in WEB-INF/lib b) describe this servlet in web.xml file.
<servlet> <servlet-name>ErrorMessage</servlet-name> <servlet-class>com.jsos.error.ErrorMessageServlet</servlet-class> </servlet> c) describe a mapping for this servlet in web.xml file
<servlet-mapping> <servlet-name>ErrorMessage</servlet-name> <url-pattern>/servlet/*</url-pattern> </servlet-mapping> in this case servlets invoker /servlet/SomeServletName will be turned off and for any such a request servlet will return error code 404 (default value). In other words mapping here describes a protected resource. Also you can describe the customized error code and error message
for this servlet. Parameters are code and message. E.g.:
<servlet> <servlet-name>ErrorMessage</servlet-name> <servlet-class>com.jsos.error.ErrorMessageServlet</servlet-class> <init-param> <param-name>code</param-name> <param-value>403</param-value> </init-param> <init-param> <param-name>message</param-name> <param-value>no-no</param-value> </init-param> </servlet> For downloading:
See also JSOS - the largest collection of servlets and filters.
|
Also in JSOS:
|