Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

context path, Servlet path and the path info doubt

 
Garlapati Ravi
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

below are two separate questions i came accross in one of the mock exams first line is question, blow one is reply

Q)music/Play/album1234?name='xyz'(assuming that the context is 'music')?
A)music, Play/album1234 and name='xyz'

Q)/books/Find/abcd?query=Java (assuming that the context is 'books')?
A)'/books', '/Find' and '/abcd'

could any one explain why the results of above two questions are different ?

Thanks,
Ravi
 
Marimuthu Madasamy
Ranch Hand
Posts: 72
Java Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For this question, the servlet-mapping element from the web.xml is required.

From the answers i guess,

For the 1st question, the url-pattern(in servlet-mapping element) for the servlet should have been '/Play/album1234' or '/Play/album1234/*'. Thats why, Servlet Path is '/Play/album1234'. So the servlet path is the one which makes the container identify that specific servlet for this request URI. For the second question, the url-pattern should have been '/Find' or '/Find/*'. Thats why, the servlet path is '/Find'

Path info follows the servlet path but precedes the query string.
So for the first question, path info = null (its wrong in the answer).
For the second question, path info = '/abcd'
 
Garlapati Ravi
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
question was not given any web.xml,
anyways your explaination is much clear. Thank You.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic