Hello,
this works for specific servlets in specific web-apps. I was curious how to turn off
the
'magic' backwards compatability mapping
of /servlet/ in general.
To be honest, I was trying to find where this default mapping is being performed. I
would have thought if I removed the prefix= attribute from the
InvokerInterceptor in servlet.xml that would have solved the issue. but that doesn't
seem to do anything.
I understand I can craft specific servlet-mappings for each application - what about
'standalone' servlets (I.e. those not in web-apps). I can always modifiy
the ROOT/WEB-INF/web.xml to cover that case, however, If I were to turn off the
/servlet/ mapping then I wouldn't have to edit all of those web.xml
files in the web-apps ( and non-webapps).
I think what I'm asking here is whether the default mapping for any given servlet is
"http[s]://<address>:<port>/[webapp]/servlet/[servlet-name]"?
It seems to me that, unless I setup a url-pattern then this is the case - I'd just like
that to be verified so I can stick it in some documentation that I'm writing :-)
thanks,
Thom
"Craig R. McClanahan" wrote:
> Thom Park wrote:
>
> > I'm having Yet Another Servlet Mapping Problem.
> >
> > I'm trying to disable the /servlet/ mapping with my web-application. Here's the
> > gist of what's happening.
> >
> > My webapp is called "songs" it get's deployed according to J2EE specs. In the
> > webapps folder there's a
> > songs folder with an html file called songs_index.html.
> >
> > in songs\WEB-INF, I put my servlet into the classes folder (and some dependent
> > jars in the lib folder).
> >
> > In web.xml I add the following:
> >
> > <servlet>
> > <servlet-name>listSongs</servlet-name>
> > <servlet-class>com.music.songs.ListSongServlet</servlet-class>
> > </servlet>
> >
>
> Add the following mapping in web.xml:
>
> <servlet-mapping>
> <servlet-name>listSongs</servlet-name>
> <url-pattern>/listSongs/*</url-pattern>
> </servlet-name>
>
> and the following URL will work:
>
> http://localhost:8080/songs/listSongs
>
> You don't really need to "turn off" the default mapping -- what we are doing here is
> defining a new one. You should also know that the path used in a mapping need not
> have the same name as your servlet class. For instance, if you change the mapping
> above to this:
>
> <servlet-mapping>
> <servlet-name>listSongs</servlet-name>
> <url-pattern>/list/*</url-pattern>
> </servlet-name>
>
> then the correct URL would be
>
> http://localhost:8080/songs/list
>
> instead.
>
> The rules for servlet mappings are found in the servlet API specification, which can
> be downloaded from
>
> http://java.sun.com/products/servlet/download.html
>
> Craig McClanahan