Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If your <code>SignIn</code> servlet is only saving a request parameter (email), then you could also replace the servlet with a <a href="https://stackoverflow.com/tags/servlet-filters/info">filter</a>, e.g. <code>SignInFilter</code>.</p> <p><code>SignInFilter</code> would contain the same logic as your <code>SignIn</code> servlet (copying the email from the request parameters to the session), but would call the next item in the chain (which will be your <code>ShowOnline</code> servlet) instead of doing any redirect/forward.</p> <pre><code>public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; HttpSession session = request.getSession(); String email = req.getParameter("email"); session.setAttribute("email", email); chain.doFilter(req, res); // continue to 'ShowOnline' } </code></pre> <p>Set up your form to POST to the <code>ShowOnline</code> servlet instead, and configure your new SignInFilter to execute before <code>ShowOnline</code> (servlet mapping omitted below for brevity).</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&gt; &lt;filter&gt; &lt;filter-name&gt;SignInFilter&lt;/filter-name&gt; &lt;filter-class&gt;com.example.SignInFilter&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;SignInFilter&lt;/filter-name&gt; &lt;url-pattern&gt;/ShowOnline&lt;/url-pattern&gt; &lt;/filter-mapping&gt; &lt;/web-app&gt; </code></pre>
    singulars
    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.
    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