title: HttpSession Null with BlobstoreService
body: <p>In my <code>Google App Engine</code> application, logged user can upload their picture with their other details. I have used <code>HttpSession</code> to manage logging. When logged user fills the form and selects a photo to upload and click on Save button, a <code>NullPointerException</code> is thrown because of <code>Session</code> is null. (Data is stored in database. but NullPointerException is thrown when trying to forward to success page after data is stored in database).</p>
  
  <pre><code>Form action = `blobstoreService.createUploadUrl("/users/adddetails")`
  </code></pre>
  
  <p>I have put <code>System.out.println(hs.getAttribute("logUserName") + "");</code> on top of the <code>servlet</code> which is trigger after click on Save button. output is <code>null</code>.</p>
  
  <p>how can i avoid this ?</p>
  
  <p><strong>UPDATED</strong></p>
  
  <p>After logged user fills the form, goes to (<code>/users/adddetails</code>) path as i mentioned in my question and add data to database. it is working properly. after data added, redirects to another servlet using <code>resp.sendRedirect()</code> method. on that servlet i'm checking whether Session is null as below.</p>
  
  <pre><code>try 
  
  { 
    HttpSession hs = req.getSession();     
  
    if(!hs.getAttribute("logUserName").equals(null)) {
        RequestDispatcher d = req .getRequestDispatcher("/WEB-INF/userhome/add_data.jsp");
        d.forward(req, resp); }
  
    else { 
        RequestDispatcher d = req .getRequestDispatcher("user_login.jsp");
        d.forward(req, resp);
    }
  
  } catch (NullPointerException ex) {
  
      // NullPointerException thrown from here
  
      RequestDispatcher d = req.getRequestDispatcher("user_login.jsp");
      d.forward(req, resp);
  }catch (Exception ex) {
      RequestDispatcher d = req.getRequestDispatcher("/msg/exception.jsp");
      d.forward(req, resp);
  }
  </code></pre>
  
  <p><code>NullPointerException</code> is thrown from <code>catch</code> block in above code. <code>logUserName</code> is the parameter which i'm using from client to server to pass around the username.</p>