• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

invoking servlets differently

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello there,
I used web.xml file in tomcat to do servlet mapping , I have directory structure like this on my system,
c:\clients\sun\TestingServlet.class , and
c:\clients\microsoft\TestingServlet.class ,
the sun\TestingServlet generates "reply from sun servlet" text,and microsoft\TestingServlet generates text "reply from microsoft servlet" , I have mapped TestingServlet in web.xml,
so what I am looking for is when I invoke
"http://server:80/servlet/clients/sun/TestingServlet" it should generate "reply from sun servlet" text and when I invoke ,
"http://server:80/servlet/clients/microsoft/TestingServlet" it should generate "reply from microsoft servlet" text.
but whatever url I use to invoke the TestingServlet it only generates "reply from sun servlet" , I am not getting "reply from microsoft servlet" text even though I use "http://server:80/servlet/clients/microsoft/TestingServlet" url to invoke servlet , what should I do get text accordingly servlets in certainn directory.
thanks.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think we would need to see the actual web.xml entries for those two servlets to figure this out.
 
ray bond
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is the entries in web.xml file where servlet mapping takes place. I have used the same servlet name but they are in different directories , one in c:\clients\sun\TestingServlet that prints reply from sun
other in c:\clients\microsoft\TestingServlet that prints reply from microsoft , but when I type http://server:8080/servlet/TestingServletsun or http://server:8080/servlet/TestingSErvletmicrosoft both of them prints "reply from sun" , how can I get reply from microsoft servlet .
<servlet>
<servlet-name>
TestingServletsun
</servlet-name>
<servlet-class>
TestingServlet
</servlet-class>
</servlet>
<servlet>
<servlet-name>
TestingServletmicrosoft
</servlet-name>
<servlet-class>
TestingServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
invoker
</servlet-name>
<url-pattern>
/servlet/*
</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>
jsp
</servlet-name>
<url-pattern>
*.jsp
</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>
TestingServletsun
</servlet-name>
<url-pattern>
/servlet/clients/sun/
</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>
TestingServletmicrosoft
</servlet-name>
<url-pattern>
/servlet/clients/microsoft/
</url-pattern>
</servlet-mapping>
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it was me, I would try the url pattern:
<url-pattern>/clients/microsoft/</url-pattern>
without the word servlet in there.
I think that this:
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
is what is controlling the response.
reply
    Bookmark Topic Watch Topic
  • New Topic