tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fedor Karpelevitch <fe...@simpata.com>
Subject RE: How to write a html filter using tomcat
Date Thu, 15 Jun 2000 14:19:02 GMT
I believe, servlet mappings are just for this. To get what you want put
something like this in web.xml:

    <servlet>
        <servlet-name>ParserServlet</servlet-name>
        <servlet-class>mypackage.ParserClass</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>ParserServlet</servlet-name>
        <url-pattern>/*.html</url-pattern>
    </servlet-mapping>

and mypackage.ParserClass will recieve all the requests for html files. You
can specify more than one mapping for the same servlet if you need to, for
instance you can make it handle *.htm as well. To do this add this:

    <servlet-mapping>
        <servlet-name>ParserServlet</servlet-name>
        <url-pattern>/*.htm</url-pattern>
    </servlet-mapping>

good luck.


> -----Original Message-----
> From: Gabriel Russell [mailto:g.russell@ieee.org]
> Sent: Thursday, June 15, 2000 6:42 AM
> To: tomcat-user@jakarta.apache.org
> Subject: How to write a html filter using tomcat
> 
> 
> I'm a little confused as to the scope of writing a html filter.
> 
> Suppose that I want to write a piece of Java that for every 
> html page get 
> served the code would filter through the html for any foreign 
> links and 
> replace the link with a click through counter.
> 
> I'd have no trouble writing the code. I just can't think of 
> how to get the 
> code to run. If I wanted to write it in c then I could simply 
> create a 
> apache response-handler. Is there a way to write 
> response-handlers with 
> tomcat? It seams like I should be able to say: for any 
> request matching 
> /foo/*.html send that request to /servlets/Parser. Parser 
> would then be 
> able to look in the request object and figure out what file was being 
> requested, open it, parse it, then dump it out. Does this make sense?
> 
> Thanks for tuning in
> Gabriel Russell
> g.russell@ieee.org
> 
> 
> --------------------------------------------------------------
> ------------
> To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commmands, email: tomcat-user-help@jakarta.apache.org
> 

Mime
View raw message