File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 232

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: 13037
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 :
I agree. Here's the link:
subject: Servlet mapping
It's not a secret anymore!