Can you call a servlet with a link? For example
<a href="/servletName">link text</a>
And possibly pass parameters to the request object by adding them to the querystring.
If not, I have seen this kind of thing:
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(/MyServlet);
dispatcher.include(request,response);
But how would I trigger this? For example if it was JavaScript code I could put it within a jQuery click function, or if this was a servlet I would put it into a method.
But how do I call this code from within a JSP. As far as I know you can’t call Java code with JavaScript events.
is perfectly legal and will work.
That will make the
doGet(..)method of the servlet be called, and you can get the parameter usingrequest.getParameter("param")