aspose file tools*
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
Author

Servlet mapping

Paul newberry
Greenhorn

Joined: Sep 07, 2011
Posts: 1
Hi

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

<servlet-mapping>
<servlet-name>ShortServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

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

squarekid
German Gonzalez-Morris
Ranch Hand

Joined: Nov 16, 2009
Posts: 191

you can put more servlet-mapping tags with the desired pattern targeting to a different servlet.


http://devwebcl.blogspot.com/
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12823
    
    5
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.

Bill
liang cheng.zhu
Greenhorn

Joined: Sep 15, 2011
Posts: 3
hello , please see the code :
<servlet-mapping>
<servlet-name>img</servlet-name>
<url-pattern>/authImg</url-pattern>
</servlet-mapping>
<init-param>
<param-name>DeniedExtensionsFile</param-name>
<param-value>
php|php3|php5|phtml|asp|aspx|ascx|jsp|cfm|cfc|pl|bat|exe|dll|reg|cgi
</param-value>
</init-param>
 
Don't get me started about those stupid light bulbs.
 
subject: Servlet mapping