aspose file tools*
The moose likes Servlets and the fly likes Map wild card url pattern to servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Map wild card url pattern to servlet" Watch "Map wild card url pattern to servlet" New topic
Author

Map wild card url pattern to servlet

Terence Thant Zin Oo
Greenhorn

Joined: Jul 08, 2006
Posts: 16
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
Marshal

Joined: Mar 22, 2005
Posts: 42950
    
  70
Why is that not possible? What have you tried?
Terence Thant Zin Oo
Greenhorn

Joined: Jul 08, 2006
Posts: 16
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
Marshal

Joined: Mar 22, 2005
Posts: 42950
    
  70
Ah, indeed - you can only map an extension or map a directory; not both at the same time.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Map wild card url pattern to servlet