On 13/04/2016 12:12, Rune Stilling wrote: > Hi list > > I have a question regarding the servlet-mapping property in web.xml. Normally > a url would look like this: > > http://host:port/context/servlet-path > > As many others I have tried to setup my servlet so that it matches the > following: > > http://host:port/ > > I’m trying to obtain this by using the following url-mapping: > > <servlet-mapping> > <servlet-name>ServletAdaptor</servlet-name> > <url-pattern>/</url-pattern> > </servlet-mapping>
You'll need to deploy your application to the root context (i.e. as ROOT.war) else you will always have a context path in the URL. > I have read the answers on these two links: > > http://stackoverflow.com/questions/4140448/difference-between-and-in-servlet-mapping-url-pattern > > <http://stackoverflow.com/questions/4140448/difference-between-and-in-servlet-mapping-url-pattern> > http://stackoverflow.com/questions/10874188/jax-rs-application-on-the-root-context-how-can-it-be-done > > <http://stackoverflow.com/questions/10874188/jax-rs-application-on-the-root-context-how-can-it-be-done> > > It’s still not clear to me why this doesn’t work (using Tomcat 7.0) You need to read section 12 of the servlet specification carefully. > I’ve have turned on Jersey tracing and this is what I get (on a url like this > http://localhost:8080/emner/81.20.00): > > X-Jersey-Tracing-004:MATCH [ ---- / 1,00 ms | ---- %] Matching path > [/] > > What’s puzzling to me is that it seems that for some reason my path gets > stripped away before reaching the servlet. I would have expected something > like this instead: > > X-Jersey-Tracing-004:MATCH [ ---- / 19,39 ms | ---- %] Matching path > [/emner/81.20.00] At a guess, "/emner" is the context path. > Is it so in Tomcat, that when you use the url-pattern “/“ that the rest of > path is ignored when interpreting the original url? No. "/" is the default servlet. > Is it different using other containers? No. > Could be related to this: > > http://bluxte.net/musings/2006/03/29/servletpath-and-pathinfo-servlet-api-weirdness > > <http://bluxte.net/musings/2006/03/29/servletpath-and-pathinfo-servlet-api-weirdness> Yes. Mark --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org