For the mapping below, I hope you tried "/foo.txt" not "/foo.ext" :-)
Christopher Hull wrote:
> Hmmm, it jsut sits there and says "Error 404, file not found /foo.ext.
> I am running Tomcat stand alone. I guess I'll keep looking around for possible
> errors, but this should be
> a simple configuration issue.
>
> Does tomcat check to see if the file exists first, before shunting to the
> servlet?
> ** Is thre a way to force Tomcat to always hit a given servlet, no matter what
> the URL? **
>
No. Tomcat looks for <servlet-mapping>s that match the URL you specify first -- the
rules are right out of the servlet spec. It tries the matching in the following
order:
* Exact match against a mapping pattern
* Prefix match against a pattern like "/foo/*".
* Extension match against a pattern like "*.txt".
* Go to the default servlet (which, in Tomcat's case, serves
the content as a file.
Your goal is to be matched at the third stage -- by the extension. A couple of
details to keep in mind:
* URL matching is case sensitive, so a pattern "*.txt" will *not* match a path
"/foo.TXT".
* The extension must be on the very last element of the path (after the last slash).
My suggestion is that you first work on this with Tomcat stand-alone. After you see
how that works, then work on the Apache config.
Craig
>
> Thanks;
> -Chris
>
> "Craig R. McClanahan" wrote:
>
> > Christopher Hull wrote:
> >
> > > I'm trying to get a servlet to fire off for a given file type. This
> > > doesn't seem to work, but the setup looks pretty straightforward.
> > >
> > > In my web.xml I set up a servlet.
> > >
> > > <servlet>
> > > <servlet-class>com.foo.aServlet</class>
> > > <servlet-name>handleFile</name>
> > > </serv.et>
> > >
> > > <servlet-mapping>
> > > <servlet-name>handleFile</s-name>
> > > <url-pattern>*.txt</url-pattern>
> > > <servlet-mapping>
> > >
> > > When I ask for the servlet directlly by name it comes up, yet when I ask
> > > for a .txt file (which exists) the servlet isn't found.
> > >
> > > Does this feature currently work in Tomcat?
> > >
> >
> > Yes, the feature works -- that is how JSP pages get mapped to the JSP servlet,
> > for example.
> >
> > One thing to note, though. If you are using Tomcat behind a web server,
> > instead of stand-alone, you will need to add an additional configuration
> > command for the web server so that it knows about this mapping also. For
> > Apache, for example, you'd need to add:
> >
> > AddHandler jserv-servlet .txt
> >
> > to make Apache aware of your desires.
> >
> > >
> > > Thanks;
> > > -Chris
> >
> > Craig McClanahan
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html