Issue
I am working on a gym management project where I am using React for frontend and backend with Java EE, but can't understand that how to connect these two pages. My frontend page have a button called Register now and I want that when I click on that button the jsp page should be open.
Solution
From your explanation, it is not clear actually what you want to do. but if you want to go directly to .jsp page after the click on the button then you can directly write
<form action="page_name.jsp">
<button>click</button>
</form>
or you can call a servlet class from there you can call the jsp by RequestDispatcher. like
<form action="/add">
<button>click</button>
</form>
@WebServlet("/add")
public class AddServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
RequestDispatcher view = request.getRequestDispatcher("/add.jsp");
view.forward(request, response);
}
}
Answered By - Ajit