title: Null point always
body: <p>It all ways passing null point after this line, <code>System.out.println("Inside the filter.............."  )</code>; so can anyone tell me what's wrong in my code and logic</p>
  
  <p>and home.jsp(index page) did not display. here I want to filter every url and proceed only valid login users requests. here my logic..</p>
  
  <p>UserServlet.java</p>
  
  <pre><code> private void loginDetail(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
  
              User u = new User();
              UserService us =new UserServiceImpl() ;
  
              String Uname = request.getParameter("txtUname");        
              String Pwrd = request.getParameter("txtPwrd");  
  
              u.setUname(Uname);
              u.setPwrd(Pwrd);
  
              System.out.println(Uname+""+Pwrd);
              try {
                  if(us.Userlogin(u.getUname(),u.getPwrd())){
                      String message = "Thank you, " + Uname +"..You are now logged into the system";             
                      request.setAttribute("message", message);
                      //RequestDispatcher rd = getServletContext().getRequestDispatcher("/menu.jsp");
                      //rd.forward(request, response); 
                      HttpSession session = request.getSession(true);
                      session.setAttribute("loggedUser", u);
                      String reqUrl = (String)session.getAttribute("requestedURL");
                      session.removeAttribute("requestedURL");
                      response.sendRedirect(reqUrl);              
                  }else{
  // direct to login}
  </code></pre>
  
  <p>FilterRequest.java </p>
  
  <pre><code>public void init(FilterConfig filterConfig) throws ServletException {
          this.filterConfig = filterConfig;
      }
  
      public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) resp;
        System.out.println("Inside the filter.............."  );
        HttpSession session = request.getSession(true);
        User u = null;
        if(session.getAttribute("loggedUser")!=null){
            u = (User) session.getAttribute("loggedUser");
        }       
        if (u!= null)
        {
            System.out.println("user does exits.." + u.getUname() );
            chain.doFilter(req, resp);          
        }else{
            String message = "Please Login!";             
            req.setAttribute("loginMsg", message);
            //response.sendRedirect("login2.jsp");
        }
      }
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>  &lt;filter&gt;
          &lt;filter-name&gt;FilterRequest&lt;/filter-name&gt;
          &lt;filter-class&gt;com.mobitel.bankdemo.web.FilterRequest&lt;/filter-class&gt;
    &lt;/filter&gt;
    &lt;filter-mapping&gt;
          &lt;filter-name&gt;FilterRequest&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
    &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>stack trace</p>
  
  <pre><code> `Jul 11, 2013 10:24:26 AM org.apache.catalina.core.AprLifecycleListener init
  INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Kaspersky Lab\Kaspersky Anti-Virus 6.0 for Windows Workstations MP4\;C:\Program Files\Java\jdk1.6.0_07/bin;C:\Program Files\MySQL\MySQL Server 5.2\bin;D:\common libs\com.mysql.jdbc_5.1.5.jar;;C:\Users\lcladmin\Documents\Softwares\java related\eclipse-jee-indigo-win32_2\eclipse;
  Jul 11, 2013 10:24:26 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
  WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:BankDemoWeb' did not find a matching property.
  Jul 11, 2013 10:24:27 AM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["http-bio-8080"]
  Jul 11, 2013 10:24:27 AM org.apache.coyote.AbstractProtocol init
  INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
  Jul 11, 2013 10:24:27 AM org.apache.catalina.startup.Catalina load
  INFO: Initialization processed in 554 ms
  Jul 11, 2013 10:24:27 AM org.apache.catalina.core.StandardService startInternal
  INFO: Starting service Catalina
  Jul 11, 2013 10:24:27 AM org.apache.catalina.core.StandardEngine startInternal
  INFO: Starting Servlet Engine: Apache Tomcat/7.0.41
  Jul 11, 2013 10:24:27 AM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["http-bio-8080"]
  Jul 11, 2013 10:24:27 AM org.apache.coyote.AbstractProtocol start
  INFO: Starting ProtocolHandler ["ajp-bio-8009"]
  Jul 11, 2013 10:24:27 AM org.apache.catalina.startup.Catalina start
  INFO: Server startup in 517 ms
  Inside the filter..............
  user does exits..`
  </code></pre>
  
  <p>Thank you..</p>