Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

<url-pattern> element

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

Any help is highly appreciated. I am facing problem with <url-pattern> element in web.xml.
I have 3 jsps, callme_v1.jsp, callme_v2.jsp and callme_v3.jsp. I have one more jsp by name callme.jsp. I want any request to callme1.jsp, callme2.jsp and callme3.jsp must be
served only by callme.jsp. when I use <url-patter>*.jsp</url-pattern>, it's working. But this pattern is not correct solution as any request to any .jsp will be served by callme.jsp

Can someone help me with this problem?

Thanks
Bharat
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You can write a Servlet Filter configured for those 3 JSPs and inside the Filter forward/Redirect the request to callme.jsp.
I am not sure thought why you would need 3 JSPs if you always want the request to be handled by callme.jsp.

Regards,
Amit
 
Bharat Makwana
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply Amit,

Instead of writing filter, right now I am using
<servlet>
<servlet-name>callme</servlet-name>
<jsp-file>/jsp/callme.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>callme</servlet-name>
<url-pattern>callme_v1.jsp</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>callme</servlet-name>
<url-pattern>callme_v2.jsp</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>callme</servlet-name>
<url-pattern>callme_v3.jsp</url-pattern>
</servlet-mapping>
<servlet-mapping>

It's working fine. Is there any drawback with this approach? ,your feed back valuable on this.

To answer your second question, from callme_v1.jsp to callme_v3.jsp are different versions used by client, callme.jsp is the jsp which is capable of serving
request for any version, dont want to break client code.
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
When I read your first post with question , I was also thinking of the option similar to what you have done. But recently we had used Filter to address some requirements I preferred that. I guess keeping servlet-name same and then assigning url-pattern for it using callme.jsp is also fine.
 
Hey, I'm supposed to be the guide! Wait up! No fair! You have the tiny ad!
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic