I have a jsp page(test.jsp) and a servlet. I have provided link in test.jsp........So,when I click on that link,it invokes the servlet and I need to pass a parameter (say a string) to the invoked Servlet...How can I do this...?Please help
Sarada Bhasker
Ranch Hand
Joined: Sep 11, 2000
Posts: 94
posted
0
create the link href value dynamically and append the string value which you want to pass. Then you can read it using request.getparameter() in the servlet.
Siva Jagadeesan
Ranch Hand
Joined: Oct 31, 2000
Posts: 160
posted
0
Append the query String in the link to the Servlet like this HelloWorldServlet?name=Siva In the Servlet the name=Siva will be appear as Request parameter. request.getParameter("name") will return "Siva" as a String
This is the code in test.jsp ... <a href="MyServlet?data=MyData">Go to server</a> ... and the servlet class : public class MyServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) { String data = req.getParameter("data"); } } Hope this help correct me if i am wrong daniel
Sarada Bhasker
Ranch Hand
Joined: Sep 11, 2000
Posts: 94
posted
0
one small change <a href=<%=Stringwhichholdstheservletanddata%> >Go to server</a>
Pandurang Shenoy
Greenhorn
Joined: Mar 31, 2003
Posts: 10
posted
0
Thanks to all for your answers
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.