Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Mohit G Gupta
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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 ?
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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"
 
Piyush Joshi
Ranch Hand
Posts: 207
Eclipse IDE Firefox Browser jQuery
  • Mark post as helpful
  • send pies
  • 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
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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 ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic