Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Map wild card url pattern to servlet

 
Terence Thant Zin Oo
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I save the images in the database and need to provide the URL to the users so that they can include in their pages.
For example, /img/a.jpg, /img/b.jpg...

I want to map /img/* to the servlet but it is not possible in Servlet version 2.4.

Have any of you encountered such problem?
If yes, please give me some suggestions.


Regards
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is that not possible? What have you tried?
 
Terence Thant Zin Oo
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf

I put the wrong url pattern in the previous post.
It should be /img/*.jpg.

I want the container to send back error 404 for other request such as /img/a/b/c.jpg or /img/a.gif.

It can be programatically (by checking request.getPathInfo()) but I want to do it in web.xml


Regards


 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, indeed - you can only map an extension or map a directory; not both at the same time.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic