aspose file tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Unable to map request to appropriate JSP using servlet-mapping in DD Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "Unable to map request to appropriate JSP using servlet-mapping in DD" Watch "Unable to map request to appropriate JSP using servlet-mapping in DD" New topic
Author

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

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634


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 ?


OCPJP 6.0 93%
OCPJWCD 5.0 98%
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

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"


[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
Piyush Joshi
Ranch Hand

Joined: Jun 10, 2011
Posts: 207

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.


Piyush
Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

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 ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to map request to appropriate JSP using servlet-mapping in DD
 
Similar Threads
RequestDispatcher and Blank Page
Deployment.
HTTP method GET is not supported error when the JSP is making POST request to the servlet
Servlet Mapping
Getting java.lang.StackOverflowError - HFSJ pg 379