Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Valve to Apache Tomcat

I wrote a Valve for Apache Tomcat by extending org.apache.catalina.valves.ValveBase class and implementing inovoke() method. Now I want to add it to my Tomcat for execution? Please show me the steps.

like image 562
andunslg Avatar asked Jun 04 '12 08:06

andunslg


People also ask

Where is the Valve element placed in Tomcat?

The Access Log valve can be associated with an engine, host, or context container. This code snippet states that the log files will be placed in the <CATALINA_HOME>/logs directory, prepended with the value localhost_access_log., and appended with the . txt suffix.

What is rewrite config in Tomcat?

The rewrite. config file contains a list of directives which closely resemble the directives used by mod_rewrite, in particular the central RewriteRule and RewriteCond directives. Lines that start with a # character are treated as comments and will be ignored.

What is SSL in Tomcat?

Secure Socket Layer (SSL) is a protocol that provides security for communications between client and server by implementing encrypted data and certificate-based authentication.

What is Tomcat Context XML?

In Tomcat, the Context Container represents a single web application running within a given instance of Tomcat. A web site is made up of one or more Contexts. For each explicitly configured web application, there should be one context element either in server. xml or in a separate context XML fragment file.


1 Answers

Create a jar with your Valve class.

Drop this into the $TOMCAT_HOME/lib folder.

Modify the server.xml to add the valve under Engine or Host tag as shown below, depending on which level you want it to operate.

 <Engine name="Catalina" defaultHost="localhost">
 <Valve className="org.whatever.MyCustomValve" />
like image 174
JoseK Avatar answered Sep 19 '22 17:09

JoseK