tags:

views:

11

answers:

1

I have a .jsp file which has to submit the request to ResultServlet

but i am getting the error

HTTP Status 404 - /project1/jsp//ResultServlet

The problem is that my ResultServlet is in /project1/src/ResultServlet

Can you tell me what changes i need to make to the action field in .jsp so that it starts looking in folder src instead of folder jsp

+1  A: 

I understand that you'd like to use a relative URL to the servlet in <form action> of the JSP. First you need to determine the full URL of both the JSP and the Servlet and then extract the relative URL to the Servlet from the JSP.

Let's assume that your JSP is on http://example.com/context/jsp/page.jsp and that your Servlet is on http://example.com/context/src/servlet. So to reach the Servlet from the JSP you have to go one level up ../ so that you lands in http://example.com/context and finally go from there to src/servlet.

<form action="../src/servlet">

Alternatively, you can also use the context path if you don't want to be dependent on the location/URL of the JSP:

<form action="${pageContext.request.contextPath}/src/servlet">
BalusC