Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can't call a servlet directly from a JSP. However, you can send a <a href="http://en.wikipedia.org/wiki/URL_redirection" rel="nofollow noreferrer">redirect</a>. This will tell the browser that it should look for the resource in another location.</p> <p>From JSP</p> <pre><code>&lt;% String destination ="/jsp/destination.jsp"; response.sendRedirect(response.encodeRedirectURL(destination)); %&gt; </code></pre> <p>From Serlet</p> <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String destination ="/jsp/destination.jsp"; response.sendRedirect(response.encodeRedirectURL(destination)); } } </code></pre> <p>If your purpose is "logging" you should use a <a href="http://www.oracle.com/technetwork/java/filters-137243.html" rel="nofollow noreferrer">Filter</a>. A Filter is like a lightweight servlet that doesn't generate its own content, instead it plugs into the request handling process and executes in addition to the normal page processing.</p> <p>A strong recommendation is to use Servlet/JSP in a <a href="http://www.stardeveloper.com/articles/display.html?article=2001060501&amp;page=1" rel="nofollow noreferrer">MVC</a> pattern way. It seperates the application's data, user interface and control logic into three separate entities. The request is handled by a Servlet (the controller) which will initialize any JavaBeans (the model) required to fulfill the user's request. The Servlet (the controller) will then forward the request, which contains the JavaBeans (the model), to a JSP (the view) page which contains only HTML and JSTL syntax.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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