I have JSP page -
<html>
<head>
</head>
<body>
<%
String valueToPass = "Hello" ;
%>
<a href="goToServlet...">Go to servlet</a>
</body>
</html>
And servlet -
@WebServlet(name="/servlet123",
urlPatterns={"/servlet123"})
public class servlet123 extends HttpServlet {
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
}
public void foo() {
}
}
What should I write in <a href="goToServlet...">Go to servlet</a>
in order to pass values (like valueToPass
or maybe add the value as argument in the ) to the servlet123
?
Can I invoke the specific method in servlet123
(like foo()
) using the link in the JSP?
EDIT:
How can I call servlet in URL? My pages hierarchy is like the following -
WebContent
|-- JSPtest
| |-- callServletFromLink.jsp
|-- WEB-INF
: :
And I want to call the servlet123
in the folder src->control .
I tried <a href="servlet123">Go to servlet</a>
but it did not find the servlet when I press on the link.
2nd EDIT:
I tried <a href="http://localhost:8080/MyProjectName/servlet123">Go to servlet</a>
and it work .