This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt about url-pattern!!

 
krishna bulusu
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys!!
This is the code in web.xml of "Myex" web-application.

<servlet>
<servlet-name>first</servlet-name>
<servlet-class>com.firstServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>second</servlet-name>
<servlet-class>com.secondServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>first</servlet-name>
<url-mapping>/eg</url-mapping>
</servlet-mapping>
<servlet-mapping>
<servlet-name>first</servlet-name>
<url-mapping>/eg</url-mapping>
</servlet-mapping>
<servlet-mapping>
<servlet-name>secondt</servlet-name>
<url-mapping>/eg</url-mapping>
</servlet-mapping>

i have two servlets with same url-patterns.
which servlet will be called if i have the fallowing url and why:
http://localhost:8080/Myex/eg
Thanks in Advance!!
regards
krishna!!
 
Senthil Kumar
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Krishna,
The application will not get deployed in first place.The mistakes you've made

1.It is not <url-mapping> it is <url-pattern>
2.there is no servlet with the name secondt
 
krishna bulusu
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry..the fallowing is the source code for web.xml

<servlet>
<servlet-name>first</servlet-name>
<servlet-class>com.firstServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>second</servlet-name>
<servlet-class>com.secondServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>first</servlet-name>
<url-mapping>/eg</url-mapping>
</servlet-mapping>
<servlet-mapping>
<servlet-name>first</servlet-name>
<url-pattern>/eg</url-mapping>
</servlet-mapping>
<servlet-mapping>
<servlet-name>second</servlet-name>
<url-pattern>/eg</url-mapping>
</servlet-mapping>
 
Senthil Kumar
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
obviously the second servlet will get called
 
krishna bulusu
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi senthill
thanks for your kind reply...
can you please explain why?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
obviously the second servlet will get called

It doesn't sound obvious, as they all have the same url pattern.
Could you please extend on that ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic