snipt

Ctrl+h for KB shortcuts

Java Server Page

Servlet to jsp forward

1
2
3
String nextJSP = "/somepage.jsp";
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
dispatcher.forward(request,response);
https://snipt.net/embed/db25fe78ee7e683bfd4718c49b28af6b/
/raw/db25fe78ee7e683bfd4718c49b28af6b/
db25fe78ee7e683bfd4718c49b28af6b
jsp
Java Server Page
4
2019-06-16T16:42:31
True
False
False
/api/public/snipt/13839/
servlet-to-jsp-forward
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>String nextJSP = &quot;/somepage.jsp&quot;; </span><span id="L-2"><a name="L-2"></a>RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP); </span><span id="L-3"><a name="L-3"></a>dispatcher.forward(request,response); </span></pre></div> </td></tr></table>
forward, jsp, servlet