title: How to access http session object in jersey REST service?
body: <p>Hi i want to access data to anf from http session object in rest service i have googled a lot and find that @context of javax.ws.rs.core.Context gives HttpServlet object but as it is interfaec i always get it null. my code is as following </p>
  
  <pre><code>@Context
  private HttpServletRequest request;
  private HttpSession session = request.getSession(); 
  
  @Path(value = "/listAllQuestion")
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  public Response listAllQuestion(){
      int pgNo = 1;
      int pgSize = 5;
      IPResponse response = new IPResponse();
      try {
          if (session.getAttribute(IpConstants.TOPIC) != null
                  &amp;&amp; session.getAttribute(IpConstants.LEVEL) != null) {
                      session.removeAttribute(IpConstants.TOPIC);
                      session.removeAttribute(IpConstants.LEVEL); 
          }                                              
          session.setAttribute(IpConstants.PAGENO, pgNo);
          session.setAttribute(IpConstants.PAGESIZE, pgSize);
          quesList = questionService.listAllQuestion(pgNo, pgSize);
  </code></pre>