Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet mapping

 
Paul newberry
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 263
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can put more servlet-mapping tags with the desired pattern targeting to a different servlet.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic