tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacob Kjome" <>
Subject RE: curious behavior - pseudo servlet-mapping with mod_jk
Date Wed, 03 Jan 2001 18:02:34 GMT
Thanks, Luc

But I'm not sure if you answered my question or not.

I understand the /servlet/ stuff and that you can even leave out any
registration of a servlet and see that servlet under, for example,
/servlet/Quiz (as long as the class is named Quiz.class with case being

The thing I'm seeing, but not sure why, is that when actaully
registering a servlet like:


you can now reference the serlvet in question by calling it with the
spelling in either the <servlet-name> or <servlet-class>.

Maybe that is what you just said.

The thing is, you can throw out the fact that Tomcat uses /servlet/ in
the default settings for the RequestInterceptor in server.xml.  That
path can be different among servlet runners.  As long as the URL in your
HTML is relative and is written like href="./quiz", you will be on
target either way.  Now, if you've gotten to the servlet successfully
already, the URL referencing back to itself will always be correct.  

The issue now becomes only "will other servlet runner
RequestInterceptor's recognize the spellings of both <servlet-name> and
<servlet-class> to invoke the Quiz.class servlet"?

I think you may have answered the above question by saying that Tomcat's
RequestInterceptor, specifically, accepts both the <serlvet-name> and
<servlet-class> spellings when referencing the servlet (that is
referencing Quiz.class as /Quiz or /quiz) in a URL but that this is NOT
a behavior that can be counted on by other servlet runner

Am I reading you correctly?


-----Original Message-----
From: Luc Vanlerberghe []
Sent: Wednesday, January 03, 2001 11:05 AM
Subject: Re: curious behavior - pseudo servlet-mapping with mod_jk

That's because you're using the InvokerInterceptor that is mapped to all
/servlet/ requests.

In your server.xml file you'll see the entry:
            debug="0" prefix="/servlet/" />

It is just a handy tool to use during development that allows you to
call any servlet without having to register it in <servlet-mapping>. 
Apparently it accepts both the class name and the servlet name to invoke
a servlet.  For servlets that are defined within a package, you'd use 
http://localhost/mycontext/servlet/xxx.yyy.mypackage.Quiz (could be that
it must be http://localhost/mycontext/servlet/xxx/yyy/mypackage/Quiz,
not sure) with Quiz being in the appropriate sub-/sub-/subdirectory
under /WEB-INF/classes.

Most servlet-containers will have a similar mechanism, but I don't think
there's really a standard, so for production you'd better use the
standard <servlet-mapping> entries.

Luc Vanlerberghe

Jacob Kjome wrote:
> I just noticed something that seems to work for me, but I can't
> quite why?  Maybe someone can confirm that this is expected behavior
> not.....
> I am running Tomcat 3.2.1 on Windows 2000
> It seems that if you have a servlet registered in web.xml like this:
> <servlet>
>         <servlet-name>quiz</servlet-name>
>         <servlet-class>Quiz</servlet-class>
> </servlet>
> AND you have the default values in mod_jk.conf:
> JkMount /mycontext/*.jsp ajp13
> JkMount /mycontext/servlet/* ajp13
> you are able to access the above servlet at either of the following
> http://localhost/mycontext/servlet/Quiz
> http://localhost/mycontext/servlet/quiz
> Notice the case difference in Quiz/quiz
> It seems that the <servlet-name> provides a rudimentary amount of
> mapping.
> I tested this theory by changing the <servlet-name> to "quiza" and
> that.  After I did that, "Quiz" and "quiza" worked, but "quiz" did
> NOTE:  This was done WITHOUT servlet mapping tags such as:
> <servlet-mapping>
>          <servlet-name>quiz</servlet-name>
>          <url-pattern>/quiz</url-pattern>
> </servlet-mapping>
> So, it seems you can very simply (without complex servlet mappings)
> your servlet case insensitive; that is in First letter upper case java
> style class naming syntax OR all lower case.
> I am not sure if this is portable accross servers!!!!!!!!!
> Can someone confirm that this isn't just a quirk of Tomcat?  Should it
> this way based on the servlet spec????  Is it portable across servlet
> runners????  Does this work on Tomcat 4.0????
> Jake
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, email:

To unsubscribe, e-mail:
For additional commands, email:

View raw message