You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Craig R. McClanahan" <Cr...@eng.sun.com> on 2000/11/18 01:29:07 UTC

Re: Servlet invoker woes - servlet-mapping /servlets/* to invoker fails on 3.2

As of Tomcat 3.2-b8 (to be created on Monday), you will be able to set a parameter in the
server.xml file to override the prefix used by the invoker servlet.  There is an entry that
looks like this:

    <RequestInterceptor
        className="org.apache.tomcat.request.InvokerInterceptor"
        debug="0" prefix="/servlet/" />

and you can change the prefix attribute to "/servlets/" for your particular case.

In Tomcat 4.0, the ability to configure global defaults in the "conf/web.xml" file is
restored to the way it worked in Tomcat 3.1 -- it is much more intuitive for things like
this.

Craig McClanahan


Rachel Greenham wrote:

> As subject: Our website uses a large number of servlets reference through
> URLs of the form /servlets/<fully-qualified-class-name>. We got this to work
> on Tomcat 3.1 by putting in a servlet-mapping tag in the webapp's WEB-INF
> file thus:
>
>     <servlet-mapping>
>                 <!--
>                 Set up a mapping to allow any URL where the path starts "/servlets/" to
>                 be invoked as a servlet.
>                 This saves us having to give all our servlets aliases and rewriting all
>                 the jphtml scripts to match!
>                 -->
>         <servlet-name>
>             invoker
>         </servlet-name>
>         <url-pattern>
>             /servlets/*
>         </url-pattern>
>     </servlet-mapping>
>
> However, this doesn't work in Tomcat 3.2 beta 7. Instead I have had to alter
> the RequestInterceptor line for the invoker in $TOMCAT_HOME/conf/server.xml
> thus, so I can get the site working today at least:
>
>         <RequestInterceptor
>             className="org.apache.tomcat.request.InvokerInterceptor"
>             debug="0" prefix="/servlets/" />
>
> Furthermore, I *had* to take out the servlet-mapping tag in the web.xml file
> as well or it still wouldn't work, which means I can't use the same web.xml
> across both versions, which creates administration headaches. Also, this way,
> there's no longer a request interceptor for /servlet/* which means, for
> example, the URLs to the servlets in the "examples" webapp no longer work. In
> other words, this configuration change is global to the servlet container,
> and can break other web applications running on it. Also, I don't know if
> it's guaranteed even to work on other servlet containers.
>
> My question is:
>
> What is the *right* thing to do here, for maximum compatibility? Is the use
> of actual servlet class names in URLs now supposed to be deprecated and
> not-to-be relied upon? Should we be using servlet aliases consistently now?
> In which case we do after all need to go through all our HTML files and other
> scripts changing URLs to use servlet aliases for all our servlets. Personally
> I suspect this is the right way, and the end result would be a cleaner
> webapp, but the person who tells our web designers to do the changes is not
> going to be popular!
>
> OR...
>
> Is the current Tomcat 3.2 beta 7 behaviour wrong?
>
> OR...
>
> Is there a more definitive way of doing this servlet mapping? I thought the
> servlet-mapping tag in WEB-INF/web.xml was unproblematic myself.
>
> --
> Rachel


Re: Servlet invoker woes - servlet-mapping /servlets/* to invoker fails on 3.2

Posted by Rachel Greenham <ra...@enetgroup.co.uk>.
On Monday 20 November 2000 19:16, you wrote:

> As I have written several times before, there is *no* standard for the
> invoker service (/servlet/* or /servlets/*).  It is *not* part of the
> servlet specification

Well, this was essentially my original question - I missed your earlier 
pronouncements on the matter - I joined the list specifically to ask the 
question after an answer didn't come up on searching the archives.

> What *is* in the standard is the servlet mappings that are defined in the
> 2.2 specification, which you can download at
> <http://java.sun.com/products/servlet/download.html>.  This is the only
> thing you can count on being portable.

That's what I reckoned; I've been poring over the specification. We *are* 
going over to using servlet aliases - we're just going to write up something 
that auto-generates our WEB-INF/web.xml. We're already auto-generating our 
.tld files.

-- 
Rachel

Re: Portability & other issues of the minute.

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
See intermixed.

Miles Daffin wrote:

> Hello to all those treading the Tomcat user trail,
>
> 1: Fully encapsulated webapps...
>
> > >
> > > Because we're trying to write nice well-behaved webapps, we don't want
> to
> > > have to change a global setting, only a local-to-webapp setting.
> > >
>
> Is it possible to set the access control stuff on a webapp local scope? I am
> talking about the stuff currently defined in 'tomcat-users.xml'.
>

In Tomcat 3.2, no.  In Tomcat 4.0, yes.

>
> It would be better in my opinion.
>
> 2: Load on start up - funny numbers
> e.g.
>   <load-on-startup>
>             -2147483646
>   </load-on-startup>
>
> Why -2147483646 here (taken from the servlet entry in main web.xml for
> org.apache.tomcat.servlets.DefaultServlet)
> and 5 in the example web.xml in the doc\appdev directory?
>

It's the most negative integer that can be represented in a 32-bit int.
Essentially, this value (or any negative value) says "I want this servlet loaded
at startup time, but I do not care what order it is loaded in."

>
> 3: How can I use ANT to compile my JSPs so I can debugger them without
> having to go through TOMCAT??
> This would be a really useful trick. I have been trying in vain to get
> Jasper to do this.
>

One approach would be to use the "jspc" command-line tool (which you can invoke
from Ant using the <exec> task).  This will precompile all of the JSP pages in
your app, and give you the source code for them (plus a chunk of stuff to stick
in web.xml for the generated servlets).

Of course, you still need Tomcat to run the JSP pages while debugging them,
because JSP pages are turned into servlets (not standalone applications).  Some
IDEs (like Forte) do this for you behind the scenes.

>
> Miles

Craig



Portability & other issues of the minute.

Posted by Miles Daffin <mi...@cwcom.net>.
Hello to all those treading the Tomcat user trail,

1: Fully encapsulated webapps...

> >
> > Because we're trying to write nice well-behaved webapps, we don't want
to
> > have to change a global setting, only a local-to-webapp setting.
> >

Is it possible to set the access control stuff on a webapp local scope? I am
talking about the stuff currently defined in 'tomcat-users.xml'.

It would be better in my opinion.

2: Load on start up - funny numbers
e.g.
  <load-on-startup>
            -2147483646
  </load-on-startup>

Why -2147483646 here (taken from the servlet entry in main web.xml for
org.apache.tomcat.servlets.DefaultServlet)
and 5 in the example web.xml in the doc\appdev directory?

3: How can I use ANT to compile my JSPs so I can debugger them without
having to go through TOMCAT??
This would be a really useful trick. I have been trying in vain to get
Jasper to do this.


Miles


Re: Servlet invoker woes - servlet-mapping /servlets/* to invoker fails on 3.2

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Rachel Greenham wrote:

> On Saturday 18 November 2000 00:29, you wrote:
> > As of Tomcat 3.2-b8 (to be created on Monday), you will be able to set a
> > parameter in the server.xml file to override the prefix used by the invoker
> > servlet.  There is an entry that looks like this:
> >
> >     <RequestInterceptor
> >         className="org.apache.tomcat.request.InvokerInterceptor"
> >         debug="0" prefix="/servlet/" />
> >
> > and you can change the prefix attribute to "/servlets/" for your particular
> > case.
>
> I already did this, on 3.2b7, the same solution works already. That's how I
> resolved the issue for now, but I wasn't happy with it, because our webapps
> weren't compatible between 3.1 and 3.2, which was worrying to say the least.
> What's needed is a *standard* solution to this problem that will work across
> all API-compliant servlet containers - ie: defined in the WEB-INF/web.xml for
> the webapp. Or I need to know for sure that there is no such standard
> solution and we should be using aliases for all our servlets. I had another
> look through the API specification and to me it looks like the latter, which
> would be a major pain.
>

As I have written several times before, there is *no* standard for the invoker
service (/servlet/* or /servlets/*).  It is *not* part of the servlet
specification -- if you'd like to encourage it to be added, you should send mail
to the address on the spec (servletapi-feedback@eng.sun.com).

What *is* in the standard is the servlet mappings that are defined in the 2.2
specification, which you can download at
<http://java.sun.com/products/servlet/download.html>.  This is the only thing you
can count on being portable.

>
> > In Tomcat 4.0, the ability to configure global defaults in the
> > "conf/web.xml" file is restored to the way it worked in Tomcat 3.1 -- it is
> > much more intuitive for things like this.
>
> Because we're trying to write nice well-behaved webapps, we don't want to
> have to change a global setting, only a local-to-webapp setting. I was able
> to do this on Tomcat 3.1.
>

Tomcat 3.2 was changed (not by me!) in ways that were gratuitously incompatible
with 3.1.  It's too late in the release cycle for 3.2 to do much about this, but
you'll be happy to know that Tomcat 4.0 returns to the approach used in Tomcat
3.1 (using the "conf/web.xml" file as global defaults for all web apps).

Note, however, that reliance on this configuration mechanism is Tomcat specific.
Basically, you should look at things this way:  "things inside my web app's
/WEB-INF/web.xml file are portable -- anything else is not.

> Rachel

Craig McClanahan



Re: Servlet invoker woes - servlet-mapping /servlets/* to invoker fails on 3.2

Posted by Rachel Greenham <ra...@enetgroup.co.uk>.
On Saturday 18 November 2000 00:29, you wrote:
> As of Tomcat 3.2-b8 (to be created on Monday), you will be able to set a
> parameter in the server.xml file to override the prefix used by the invoker
> servlet.  There is an entry that looks like this:
>
>     <RequestInterceptor
>         className="org.apache.tomcat.request.InvokerInterceptor"
>         debug="0" prefix="/servlet/" />
>
> and you can change the prefix attribute to "/servlets/" for your particular
> case.

I already did this, on 3.2b7, the same solution works already. That's how I 
resolved the issue for now, but I wasn't happy with it, because our webapps 
weren't compatible between 3.1 and 3.2, which was worrying to say the least. 
What's needed is a *standard* solution to this problem that will work across 
all API-compliant servlet containers - ie: defined in the WEB-INF/web.xml for 
the webapp. Or I need to know for sure that there is no such standard 
solution and we should be using aliases for all our servlets. I had another 
look through the API specification and to me it looks like the latter, which 
would be a major pain.

> In Tomcat 4.0, the ability to configure global defaults in the
> "conf/web.xml" file is restored to the way it worked in Tomcat 3.1 -- it is
> much more intuitive for things like this.

Because we're trying to write nice well-behaved webapps, we don't want to 
have to change a global setting, only a local-to-webapp setting. I was able 
to do this on Tomcat 3.1.

-- 
Rachel