File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Giving same name for URL pattern in web.xml

 
swarupa patil
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rancher
Can we give the same name to URL pattern that already has been given?
If yes which resouce is sent back to client?Please Help
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you want to do such a thing?
 
swarupa patil
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interviewer asked me this question and excepting detail answer
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try it?
What happened?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that how he worded the question?
Was he asking if you can use the same url pattern for two different mappings?

Or.....

Was he asking if you can map to different url patterns to the same servlet name?
 
swarupa patil
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried this in Tomcat5.028 server I get result
Server doesnot throw any excetion.
But result is unexpected. I hope i got first resource
which has already used this name. But it displays different
Can u answer this how it works?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read my last question.
We may have had our last two posts cross.

Without knowing exactly what the interviewer asked you, it would be hard to give you an answer.
 
swarupa patil
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you use the same url pattern for two different (resources)mappings?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I can't see the sense in asking such a question.
Maybe you misunderstood him.

Section 10 of the servlet spec (link in my signature) covers url patterns.

It would make sense for him to ask you about multiple mappings pointing to the same resources. It would also make sense if he asked about the a given request matching two different mappings.
Example
if the request was:
http://www.javaranch.com/myServlets
and you had two mappings that matched this pattern


In this case, section 10 of the servlet spec clearly states which of the two mappings should be used.
Now that I think of it, this must have been what he was asking.
There is no logical reason for the servlet spec to give directions for handling two mappings with identical url-patterns.
[ June 01, 2006: Message edited by: Ben Souther ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic