• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What's going on? Servlet mapped: "/" now can't find any images/stylesheets!

 
Robert Paris
Ranch Hand
Posts: 585
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mapped my servlet to "/" and now no images or stylesheets can be found. Why is it grabbing every single request to the website? I only wanted it to grab "/" requests, but now it grabs ANY AND ALL requests to anything!
 
Frank Carver
Sheriff
Posts: 6920
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, that's an old chestnut.
The spec (still, as of 2.3, at least) implies that a URL pattern ending with '/' is treated as a prefix, and thus a pattern of '/' matches anything and everything.
The usual way to solve it is to define a "welcome-file" in your web.xml which will handle the case of the user supplying just the '/', then map your active content to something else eg.
web.xml:

Then put an "instant redirect" into your welcome file:
index.html

This works for me. Apparently in version 2.4 of the servlet API, you can directly specify a servlet as the "welcome-file", so you don't need the jiggery-pokery with the redirect.
I do really wish there was a way of specifying an "exclude pattern" of some sort, so I could say "send everything to my servlet, except URLs beginning with '/images'". Sigh.
 
Mark Howard
Ranch Hand
Posts: 285
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frank
Is the web.xml file that you're updating the one in the default ROOT directory, or the one specific to your web app?
I essentially want a url of www.mysite.com to fire up a specific servlet in my web application.
I thought I could simply create an index.jsp file that merely forwarded the request to the desired servlet, and get the welcome-file to point to the index.jsp file.
But when I type in www.mysite.com I still end up with the default Tomcat index.jsp file
Something is obviously in the wrong place. Can you help?
Thanks a mil
Mark.
 
Sam Walker
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don�t know if this applies to your situation but here is my two cents. If you�re deploying under apache your index.jsp will not get picked up. In that case you need to redirect your request to index.jsp from index.html.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic