• 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

Unable to map request to appropriate JSP using servlet-mapping in DD

 
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

t1.jsp

t2.jsp


When I request for t1.jsp i.e http://localhost:8080/Scwcd/t1.jsp
and click submit button,it takes to t2.jsp as specified in the mapping.
address: http://localhost:8080/Scwcd/tests/b.jsp
browser output:

T2jsp------t1jsp /tests ---------
______
|submit|
_______

when I click on the the submit button on this page it takes to
address:http://localhost:8080/Scwcd/tests/tests
browser output:

T2jsp------t1jsp /tests ----------
______
|submit|
_______


The address URL changes but the broswer output is same as of t2.jsp
broswer output should be of t1.jsp i.e.


t1jsp------t2jsp
______
|submit|
_______


q1.Why am I getting such behaviour ?

-----------------------------------------------------------------------------------------------------------------
If i remove the following code from web.xml,the request from t2.jsp is mapped to /tests/*.



should'nt the request for tests in the form tag i.e.
t2.jsp


go to an error page eg-"page not found" as no match would be found for it for tests.
THough there is a mapping to /tests/* but its different from tests.

q2.Why is the request from t2.jsp is mapped to /tests/* if code as specified above is removed from web.xml ?
 
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe the problem with "/test" is that you do not have a page with that name. That is why it need the*.

I have a problem with mapping with servlet once and to solve it I had do point the form action like: "/YOUR_APP/action"
 
Ranch Hand
Posts: 207
jQuery Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

mohitkumar gupta wrote:
t1.jsp

t2.jsp




Step 1: You go to http://localhost:8080/Scwcd/t1.jsp and click submit button and t2.jsp opens.

Step 2: Right now address is http://localhost:8080/Scwcd/tests/b.jsp
now when you click on submit, the action is "tests" which is a relative address.
That means that the request will go for http://localhost:8080/Scwcd/tests/tests
Container looks for any direct matches for url pattern /tests/tests but it does not find any, So then it looks for /tests/* and finds it to be mapped to TestS1 which is t2.jsp.

I dont see any unexpected behavior. It is what it should be.
 
Mohit G Gupta
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Piyush and Hebert
q1 is solved but what can be the reason for the query 2 i.e.

q2.Why is the request from t2.jsp is mapped to /tests/* if code as specified above is removed from web.xml ?
 
If somebody says you look familiar, tell them you are in porn. Or in these tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic