Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Links generate GET requests. So if you want to execute some Java code during a GET request, you need to create a Servlet which has the <code>doGet()</code> implemented and execute the desired code logic accordingly. </p> <p>If necessary, you can pass request parameters using the usual query string way like <code>href="myservlet?name1=value1&amp;name2=value2"</code> or -more SEO friendly- as part of the path like <code>href="myservlet/value1/value2"</code> which you can access using <code>HttpServletRequest#getPathInfo()</code>.</p> <p>After processing the request, the servlet needs to forward the request to a JSP to display the page. This can be done by <code>request.getRequestDispatcher("page.jsp").forward(request, response)</code>. </p> <p>The servlet class behind <code>myservlet</code> is obviously to be mapped on an <code>url-pattern</code> of <code>/myservlet/*</code>.</p> <p>Hope this helps.</p> <p>[Edit] as one of your later comments reveals, you'd like to pass request scoped data to the next request. This case, just pass them along to the next request as request parameters. If they are already available as request parameters, then just do:</p> <pre><code>href="myservlet?name1=${param.name1}&amp;name2=${param.name2}" </code></pre> <p>Otherwise, if they're only available as model data, then do something like:</p> <pre><code>href="myservlet?name1=${data.name1}&amp;name2=${data.name2}" </code></pre> <p>Inside the <code>doGet()</code> method you can reobtain them the usual way by <code>HttpServletRequest#getParameter()</code>.</p> <p>Good luck.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload