I am really struggling to figure out why I can't get to my servlet when submit my form. I have tried changing the path in the xml multiple times and edited the servlet code, but my browser still can't find my servlet when I submit the form.
Here is the web.xml:
<?xml version="1.0"?>
<web-app>
<servlet>
<servlet-name>quizServlet</servlet-name>
<servlet-class>quiz</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>quizServlet</servlet-name>
<url-pattern>/quiz</url-pattern>
</servlet-mapping>
</web-app>
I have also tried having form3/quiz be the url-pattern.
Here is the simple servlet:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class quiz extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><body>");
String grade = request.getParameter("grade");
out.println("grade=" + grade);
out.println("</body></html>");
out.close();
}
}
And here is the html:
<html>
<body>
Quiz
<form method='post' action='quiz'>
grade<input type='text' name='grade'>
<input type='submit'></form>
</body>
</html>
index.html is contained in webapps/simpleForms/form3, web.xml is in webapps/simpleForms/form3/WEB-INF and quiz.java is in webapps/simpleForms/form3/WEB-INF/classes and is compiled.