File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes What's going on? Servlet mapped: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "What Watch "What New topic
Author

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

Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
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

Joined: Jan 07, 1999
Posts: 6920
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.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Mark Howard
Ranch Hand

Joined: Feb 14, 2001
Posts: 285
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

Joined: Nov 06, 2002
Posts: 65
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
 
subject: What's going on? Servlet mapped: "/" now can't find any images/stylesheets!
 
Similar Threads
Problem with deploying servlet
Default Page, How?
Difference between a URL and URI
JSP with CSS does not display the background image
HTTP Status 404