tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject Re: How do you set up a jsp action/filter for all documents in a directory
Date Fri, 26 Apr 2002 23:48:45 GMT

It wouldn't make a whole lot of sense to do this with a .jsp file.  Just 
use a servlet who's only job is to process the files.

in your web.xml...

<servlet>
         <servlet-name>fileprocessor</servlet-name>
         <servlet-class>com.mycompany.MyFileProcessor</servlet-class>
</servlet>
<servlet-mapping>
         <servlet-name>fileprocessor</servlet-name>
         <url-pattern>/myfiles/*</url-pattern>
</servlet-mapping>


Then, in the MyFileProcessor servlet, just use req.getPathInfo() and 
req.getPathTranslated() to get the needed path to the file to process.

So,

http://mycompany.com/mycontext/myfiles/humor/2002/04/26/humor8.html

Would actually call the MyFileProcessor servlet and....

req.getPathInfo() == /humor/2002/04/26/humor8.html
req.getPathTranslated() == C:\myfiles\humor\2002\04\26\humor8.html

Now that you have file system access to the .html file, you can load it up 
and do whatever you want with it before you send it back out in the response.

Jake



At 10:46 PM 4/26/2002 +0100, you wrote:
>Dear Team
>
>I've set up a test-bed Apache/Tomcat installation on my W2K box that is
>working fine. I just cannot figure out how to configure the following:
>
>I have a directory of files that can be served by Apache. Let say they are
>in directory
>"C:\myfiles". I can set up an Apache alias
>
>   Alias /myfiles/ "C:/myfiles/"
>
>and thus get to them through the Apache server.
>
>However, the HTML files in this directory need some translation before they
>get served. So when Apache is asked to serve, say, "/myfiles/afile.html" I
>need a "jsp" to be run, that is given the original file path to read so it
>can provide the translated response.
>
>I remember doing this with cgi once using the ScriptAliasMatch directive.
>
>I've got as far as adding
>
>     JkMount /myfiles ajp13
>     JkMount /myfiles/* ajp13
>
>but have not got any further...
>
>Does anyone know how to do this with Apache/Tomcat?
>
>Many thanks
>
>Paul
>
>
>
>--
>To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
>Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message