• Post Reply Bookmark Topic Watch Topic
  • New Topic

<url-pattern> element

 
Bharat Makwana
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • 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
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!