I have jsp page -पास मूल्यों <a href>
<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 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 follow -
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 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 .
धन्यवाद, इसलिए यदि मैं उपयोग URL का उपयोग करता हूं जैसे "goToServlet? Param1 = value1 और param2 = value2" सर्वलेट में कौन सी विधि लागू की जाएगी? डूगेट? – URL87
आपको डूगेट का उपयोग करना चाहिए। इस उत्तर पर एक नज़र डालें: http://stackoverflow.com/a/2349741/980472 – jddsantaella
ठीक है। अंतिम प्रश्न, मेरी संपादित पोस्ट देखें। – URL87