This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Servlet mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet mapping" Watch "Servlet mapping" New topic

Servlet mapping

Paul newberry

Joined: Sep 07, 2011
Posts: 1

I am writing a url shortener and have mapped a servlet to take carer of the redirecting


so everything after the / becomes a key which then gets looked up in a database and the servlet does a redirect. The problem is that I don't want to servlet to intercept certain types of urls such as mysite/styles.css mysite/site.js is there anyway to say url pattern matches everything other than patterns that end in .css and .js , I don't know if its possible to do it using a regular expressions.

Many Thanks

German Gonzalez-Morris
Ranch Hand

Joined: Nov 16, 2009
Posts: 160

you can put more servlet-mapping tags with the desired pattern targeting to a different servlet.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12761
Sounds like you may be re-inventing the concept of Restful web services where the rest of the URL describes a resource rather than specifying a servlet.

liang cheng.zhu

Joined: Sep 15, 2011
Posts: 3
hello , please see the code :
Consider Paul's rocket mass heater.
subject: Servlet mapping
Similar Threads
Spring 3 not calling .html and servlet is not available
Executing Servlet File using Tomcat
Multiple url-pattern in filter-mapping OC4j Servlet 2.5
Start with a Servlet in Weblogic 6.x
package issue