Protect servlets ver. 1.4

This small servlet redirects users to the home page of your web applications. You can use it to prevent your clients from direct using URLs like http://your_host/your_web_app/servlet/YourServletName to bypass your security settings and/or filters that could be associated with custom URLs in your web applications.

How to use it:

a) download protectPackage.jar and save it in WEB-INF/lib

b) describe this servlet in web.xml file.
 


<servlet>
  <servlet-name>protect</servlet-name>
  <servlet-class>com.jsos.protect.protectServlets</servlet-class>
</servlet>

c) describe a mapping for this servlet in web.xml file
 


<servlet-mapping>
  <servlet-name>protect</servlet-name>
  <url-pattern>/servlet/*</url-pattern>
</servlet-mapping>

in this case servlets invoker /servlet/SomeServletName will be turned off. protectServlets simply redirects all such requests to the home page of your web application (defined by getContextPath() call).

Also you can describe a special page for redirection as an initial parameter for this servlet. Parameter name is home. An optional parametere exclude lets you exclude some of your servlets from the processing. Parameter exclude contains a commas separated list of names excluded from the processing.E.g.:
 


<servlet>
  <servlet-name>protect</servlet-name>
  <servlet-class>com.jsos.protect.protectServlets</servlet-class>
  <init-param>
   <param-name>home</param-name>
   <param-value>http://www.acme.com</param-value>
   </init-param>
  <init-param>
   <param-name>exclude</param-name>
   <param-value>/servlet/download,/servlet/redirect</param-value>
   </init-param>
</servlet>

In this case the following requests /servlet/download and /servlet/redirect are valid.

   For downloading:
    Protect package:  protectPackage.jar
 

 ©  Coldbeans     Comments?

See also Coldtags suite - the largest collection of custom JSP tags.

Also in JSOS: