I keep getting this error when I hit the submit button, the doPost() method in the servlet is not getting called. I am using Eclipse and running the project on an Apache server. Upon hitting submit, the page should be redirected to ShowConfirmMake.ftl which basically just prints out that the user has registered successfully. Here is the code for the servlet:
public class UUGUI extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* doGet contains the register form
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
// set pagetitle und navtype
request.setAttribute("navtype", "unregistereduser");
request.setAttribute("pagetitle", "register");
// Dispatch request to template engine
try {
request.getRequestDispatcher("/templates/defaultWebpageuu.ftl").forward(request, response);
} catch (ServletException | IOException e) {
e.printStackTrace();
}
}
/**
* Contains handling of Register call
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) {
System.out.print("not registering");
request.setAttribute("navtype", "unregistereduser");
// Check wether the call is insertOffer or not
if (request.getParameter("action").equals("register")) {
// Append parameter of request
String name = (String) request.getParameter("name");
String email = (String) request.getParameter("email");
int age=Integer.parseInt(request.getParameter("age"));
// Call application to insert offer
new MRApplication().RegisterUser(name, email, age);
// Dispatch message to template engine
try {
request.setAttribute("pagetitle", "register");
request.setAttribute("message", "Successful Registered");
request.getRequestDispatcher("/templates/showConfirmMake.ftl").forward(request, response);
} catch (ServletException | IOException e) {
e.printStackTrace();
}
// Call doGet if request is not equal to insertOffer
} else
doGet(request, response);
}
}
And the html code for the form is:
<#include "header.ftl">
<b>Welcome to our little demonstration on the MR Webapp</b><br><br>
<form method="POST" action="unregistereduser?action=register">
<fieldset id="registeruser">
<legend>Required Information</legend>
<div>
<label>name</label>
<input type="text" name="name" id="name">
</div>
<div>
<label>email</label>
<input type="email" name="email" id="email">
</div>
<div>
<label>age</label>
<input type="number" name="age" required min = "18">
</div>
</fieldset>
<input type="submit" name="submit" value="Submit"/>
</form>
<#include "footer.ftl">