Skip to main content

HOW TO write a custom Tomcat Valve for Borland Webcontainer

  • February 15, 2013
  • 0 replies
  • 0 views

Problem:

  • Product Name: Borland Enterprise Server
  • Product Version: 5.2.1
  • Product Component: WebContainer
  • Platform/OS Version: All
  • JDK/Compiler Version: JDK 1.4.1


BES5.2.1 HOWTO write a custom Tomcat Valve for Borland Webcontainer

Resolution:

The following is an example Tomcat Valve which modifies the request. Installation instructions are noted in the example source comments. Note the
valve here does not differ from a valvle who would run in a stand alone tomcat.

To learn more about Tomcat Valves, their capabilities, and when a user may want to implement them please visit  http://jakarta.apache.org/tomcat/tomcat-4.1-doc/catalina/docs/api/org/apache/catalina/Valve.html


 // BEGIN EXAMPLE SOURCE
 /*
 * This is a Valve that modifies the request.
 *
 * How to Build
 * --------------------
 *
 * Compile this source with the following jars in CLASSPATH
 *
 * ${bes.home}/lib/tomcat/server/catalina.jar
 * ${bes.home}/lib/tomcat/common/servlet.jar
 *
 * How to install
 * --------------
 *
 * Jar this class and drop into [bes]/lib/tomcat/server/patches
 * directory
 *
 * Add the following under the correct (HTTP or IIOP or both) Engine
 * element of your server.xml
 *
 *
 *
 * Restart the BES partition.
 */

 package example.valves;

 import org.apache.catalina.valves.ValveBase;
 import java.io.IOException;
 import javax.servlet.ServletException;
 import org.apache.catalina.Request;
 import org.apache.catalina.Response;
 import org.apache.catalina.Valve;
 import org.apache.catalina.ValveContext;

 public class TomcatValveEx extends ValveBase {
 
   public String getInfo() {
       return "CiscoSSMValve";
   }


   public void invoke(Request request, Response response,ValveContext context)
   throws IOException, ServletException {

       System.out.println("Example VALVE hit");
       // do the following on detecting header
       request.setSecure(true);
       request.setScheme("https");

       // complete the chain
       context.invokeNext(request, response);
   }
 }
 // END EXAMPLE SOURCE


#VisiBroker
#Security
#tomcat
#WebContainer