Note that there are some explanatory texts on larger screens.

plurals
  1. POSession ID not the same in my java ee application
    primarykey
    data
    text
    <p>Ive written a application with a custom login system. And then written my own security filter for it which sets the area that can be accessed. Yet i always get redirected to the login page and then to the index page with is the logged in home page. I have discovered that the session ID is different from when i login to when i try to use something that is restricted. Here is my code:</p> <pre><code>public class securtityFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { //To change body of implemented methods use File | Settings | File Templates. } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) servletRequest; // if there is no userBean, then they have not gone through // the login, so kick them to the login page if(null==req.getSession().getAttribute("username")) { ((HttpServletResponse)servletResponse).sendRedirect("../Login.jsp"); System.out.println("Redirected - No session"); } // otherwise, let them go to the page/resource they want filterChain.doFilter(servletRequest, servletResponse); System.out.println("Gone through Filter"); // System.out.println("In Filter Servlet: "+ req.getSession().getId()); } public void destroy() { //To change body of implemented methods use File | Settings | File Templates. } </code></pre> <p>}</p> <p>Here is my web.xml file:</p> <pre><code> &lt;filter&gt; &lt;filter-name&gt;SecurityFilter&lt;/filter-name&gt; &lt;filter-class&gt;filters.securtityFilter&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;SecurityFilter&lt;/filter-name&gt; &lt;url-pattern&gt;/add/*&lt;/url-pattern&gt; &lt;/filter-mapping&gt; </code></pre> <p>So if anyone can help me with this problem them please. If you would like anymore code then let me know. Thanks in advance Dean </p>
    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.
 

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