Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet mapping and image access

 
Pawanpreet Singh
Ranch Hand
Posts: 264
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic