Session ID not the same in my java ee application -


I wrote an application with a custom login system, and then wrote my own security filter for that which Sets the area that can be accessed. However, I am always redirected to the login page and then on the index page with the log in the home page. I have found that session ID is different when I try to use the thing which is restricted when I login. Here is my code:

  Public class securitizer tool filter {Public Zero Init (FilterConfig filterConfig) throws ServletException {// Use the file to change the body of the implementation methods. Settings | File templates} Public Zero doFilter (ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {HttpServletRequest req = (HttpServletRequest) servletRequest; // If there is no user, they have not gone via // login, then kick them on the long page if (null == req.getSession (). GetAttribute ("user name")) ((httppservate Response) Servlet Response) .seendRedirect ("../ Login.jsp"); System.out.println ("Redirected - No Session"); } // Otherwise, let them go to Page / Resources, they want Chain.doFilter (servletRequest, servletResponse); System.out.println ("went through the filter"); // System.out.println ("Filter Servlets:" + req.getSession (.) GetId ()); } Public Zero Destroy () {// Use the file to change the body of the implementation methods. Settings | File templates}  

}

My web here The Xml file is:

  & lt; Filter & gt; & Lt; Filter-name & gt; SecurityFilter & lt; / Filter-name & gt; & Lt; Filter range & gt; Filters.securtityFilter & lt; / Filter range & 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;  

So if anyone can help me with this problem please tell me if you would like code now thank you in advance

In your login service you have

  while (Rsnext ()) {Https session session = request.getSession (true); String tmp = rjest string (1); Println (tmp); Session.setAttribute ("user name", tmp); Count ++; }  

So if your session does not have a username, it is because this code block is not being executed. I think that you are looping through the results of a database query, so check that the actual query that you are performing returns any results.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -