Call a servlet on click of hyperlink
. request.getContextPath() is used to return the portion of the request URL and specifies the context of the request. You have to put the servlet url of desired servlet as href="<%=request.getContextPath()%>/CallServlet? . CallServlet is the url of the Servlet.
<html> <head> <title>Calling servlet</title> </head> <body> <h2>Click on bellow hyperlink to call a servlet</h2><br/> <a href="<%=request.getContextPath()%>/ServletConstructor">Click to call servlet</a> </body> </html>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.