wood burning stoves 2.0*
The moose likes Servlets and the fly likes servlet mapping and image access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet mapping and image access" Watch "servlet mapping and image access" New topic
Author

servlet mapping and image access

Pawanpreet Singh
Ranch Hand

Joined: Jun 12, 2005
Posts: 264

Hi Everybody,

I am facing some problem during servlet mapping and accessing images under same context.

I have one servlet controller only that dispatches the request to all handler classes. I do request like

http://localhost:8080/controller/parameter1/page1
http://localhost:8080/controller/parameter1/page2
http://localhost:8080/controller/parameter1/page3

Here in above path, parameter1 value is variable and controller and page1 tokens are fixed. So i cant decide a fix value for url-pattern.

For such case, i used value following value in url-pattern under <servlet-mapping>

<servlet-mapping>
<servlet-name>lwrfrontcontroller</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

By doing this, i have achieved my target, but one problem i am facing, that i have some images in under controller context, so how to get those, /* is making problem for that, suppose in my jsp, if i have image like
<img src="/controller/images/one.gif"/>, this request again goes to controller instead of displaying the image (/* problem).

Could any body help me to sort out this problem.

Thanks in advance.

==Pawan==
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

This is more of a general servlet question than a Tomcat specific one so I'm going to move it to the Servlets forum for you.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The URL pattern:
<url-pattern>/*</url-pattern>

Tells the container that you want ALL requests to be handled by the specified servlet.

You may want to come up with a more specific pattern.
Struts came up with the *.do extension for this purpose.
Other people create a /servlet/* or /action/* directory structure for this.
 
wood burning stoves
 
subject: servlet mapping and image access
 
Similar Threads
Serving static assets from a servlet
Problem with URL-PATTERN tag
Servlet Contrlloer Path Issue
The requested resource is not available
Servlet Context Virtual Sandbox