When i run my Mavenproject in Eclipse on the index.jsp it opens it. Than i am trying to open my AdressServlet trough /EnterAddress here i get the error.
Index.jsp:
<html>
<body>
<h2>Welcome</h2>
<p>
We are going to get started with some question.
First we will need some information about you.
</p>
<a href="/EnterAddress">Start</a>
</body>
</html>
AddressServlet:
package Servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import Bean.SurveyBean;
import Service.SurveyService;
@WebServlet(value = "/EnterAddress", initParams = {
@WebInitParam(name = "addressPage",
value = "/WEB-INF/pages/Address.jsp"),
@WebInitParam(name = "QuestionURL", value = "Question") })
public class AddressServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public void init() throws ServletException{
super.init();
}
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
SurveyBean bean = new SurveyBean();
HttpSession sess = req.getSession();
sess.setAttribute("surveyBean", bean);
resp.sendRedirect("/pages/Address.jsp");
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
HttpSession sess = req.getSession();
SurveyBean bean = (SurveyBean) sess.getAttribute("surveyBean");
bean.setName(req.getParameter("name"));
bean.setStreet(req.getParameter("street"));
bean.setNumber(req.getParameter("number"));
bean.setZipcode(req.getParameter("zipcode"));
bean.setCity(req.getParameter("city"));
bean.setEmail(req.getParameter("email"));
sess.setAttribute("surveyBean", bean);
}
}
web.xml:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
Address.jsp:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form method="POST">
Name: <input type="text" name="name"/>
Street: <input type="text" name="street"/>
Number: <input type="text" name="number"/>
Zipcode: <input type="text" name="zipcode"/>
email: <input type="text" name="email"/>
<input type="submit" value="OK"/>
</form>
</body>
</html>
I have no idea why i get the error. I don't get a error on index.jsp. But when i press Start on de jsp i get the error
When i do the things edited by BalusC It still doesn't work i have no idee what i am doing wrong or how i can fix it