I have 3 links, Teacher, Student, and Employees. When clicked on any links, I want them to go to the Selection servlet and the servlet will check what link was selected. After that, it will forward it to the desired JSP page. I am not sure how to do that.
Here is my code so far:
JSP File:
<!DOCTYPE html>
<html>
<head>
<title>Selection</title>
</head>
<body>
<h2>Please Choose One</h2>
<a name="select" value= "Teacher" href="UserSelection"> Teacher </a> <!-- Not sure if I need name and value -->
<a name="select" href="UserSelection"> Student </a>
<a name="select" href="UserSelection"> Employee </a>
</body>
</html>
Selection Servlet:
@WebServlet("/UserSelection")
public class UserSelection extends HttpServlet
{
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String selection = request.getParameter("select");
if("Teacher".equals(selection))
{
System.out.println("Teacher");
}
}
}