Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question on Servlet mapping  RSS feed

 
Manish Ramrakhiani
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to call my servlet for all the url patterns for */FCExporter, however servlet mapping like



seems inappropriate.

Basically i want to hit this servlet whenever the last token is /FCExporter.

Any pointers..how this can be done?

Thanks,
Manish Ramrakhiani
 
Kunal Lakhani
Ranch Hand
Posts: 622
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
view plaincopy to clipboardprint?
<servlet-mapping>
<servlet-name>FCExporter</servlet-name>
<url-pattern>*/FCExporter</url-pattern>
</servlet-mapping>

seems inappropriate.

Basically i want to hit this servlet whenever the last token is /FCExporter.



Why it seems inappropriate?

You would have configured <servlet> tag with <servlet-name> & <servlet-class>. And everytime whenever the request is from "/FCExporter", your servlet class (configured in <servlet-class>) will be called,provided you have correctly configured it.

Also remember, does not refers to servlet class
 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes as kunal said <servlet-name> which is configured in web.xml is used during object creation of your servlet component/program by the container..
you can see it practically when you execute your web application,just look the log files or tomcat.exe console application.... you can know each and every activity done on your servlet program by the container even you can see the exceptions also.. when encountered...

 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but url pattern can be of three type:

1)exact match.. example:
here the url pattern starts with "/" can have any charactters except *,where * include , .extension etc
<url-pattern>/myurlpattern</url-pattern>

2)extension-match:
<url-pattern>*.extension</url-pattern>//*-->can be abc,123or even abc/123/a/b
(so on) ...
example:

<url-pattern>/abc.c</url-pattern>//here .c is the extension and must be at last
<url-pattern>/a/b/c.do/123.x</url-pattern>//

3)directory match:
must begin with "/" and end with "*",multiple words or characters must be seperated by "/'
example:
<url-pattern>/abc/x/y/z.c</url-pattern>

if you write any url-pattern other than the above (not as in examples) url patterns that is exact match,extension match,directory match) then container doesn't recognize the url pattern mentioned in web.xml more over you get exception...


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!