Roshan
Roshan

Reputation: 645

HTTP Status 404, error: The requested resource is not available

Trying out a simple application of session using Eclipse IDE. I have register.jsp inside WebContent/pages/ and RegistrationServlet.java is under package com.pg.controller

i have the below code in my jsp page register.jsp

<form action="RegistrationServlet" method="post">
<table>
    <tr>
        <td>Email</td><td><input type="email" name="email" /></td>
    </tr>
    <tr>
        <td>Password</td><td><input type="password" name="password" /></td>
    </tr>
    <tr>
        <td>Confirm Password</td><td><input type="password" name="confirm" /></td>
    </tr>
        <tr>
        <td>User type </td><td><select name="role"><option>Tenant</option><option>Owner</option></select></td>
    </tr>
    <tr>
        <td><input type="reset" value="Reset" /></td><td><input type="submit" value="Register" /></td>
    </tr>
</table>
</form>

this is my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>PayingGuest</display-name>

  <servlet>
   <servlet-name>RegistrationServlet</servlet-name>
   <servlet-class>com.pg.controller.RegistrationServlet</servlet-class>
  </servlet>

 <servlet-mapping>
   <servlet-name>RegistrationServlet</servlet-name>
   <url-pattern>/RegistrationServlet</url-pattern>
 </servlet-mapping>

</web-app>

the RegistrationServlet.java has the following code to forward the request,

request.getRequestDispatcher("test.jsp").forward(request, response);

and test.jsp is in the same folder in which register.jsp is but still i get the mentioned error. Something right i had missed doing in this??

Upvotes: 0

Views: 642

Answers (1)

Ian McLaird
Ian McLaird

Reputation: 5585

You need to use

request.getRequestDispatcher("/pages/test.jsp").forward(request, response);

The RegistrationServlet is mapped to the root of the context, so using a relative path will be relative to that, not to register.jsp.

Upvotes: 2

Related Questions