Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

invoking servlets differently

 
ray bond
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • 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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13062
6
  • Mark post as helpful
  • send pies
  • 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
  • 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
Rancher
Posts: 13062
6
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic