I am working on a small EJB application..I have a JSP page with a form where user fill its details and on button click it is being send to a servlet page where the data is to be added through my entity class.But when I click on the button on JSP page, I am getting the following error
HTTP Status 404 -
type Status report
message
descriptionThe requested resource () is not available.
GlassFish Server Open Source Edition 3.1.2.2
My servlet page Contactservlet.java is
public class Contactservlet extends HttpServlet {
@EJB
private AbstractFacade cfl;
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try
{
String name=request.getParameter("name");
String mail=request.getParameter("mail");
String phn=request.getParameter("phn");
String cmnt=request.getParameter("cmnt");
Contact c=new Contact();
c.setCmnt(cmnt);
c.setMail(mail);
c.setName(name);
c.setPhn(phn);
cfl.create(c);
}
catch(Exception ex)
{
out.println(ex);
}
}
My web.xml file is :
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>Contactserv</servlet-name>
<servlet-class>Contactservlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Contactserv</servlet-name>
<url-pattern>/Contactserv</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Code for my JSP file is
<form action="Contactservlet">
Name <input type="text" name="name"/>
Mail <input type="text" name="mail"/>
Phone <input type="text" name="phn"/>
Comment <input type="text" name="cmnt"/>
<input type="submit" name="bt" value="Submit"/>
</form>