Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

How to restore a session in a Servlet created in another Servlet on Glassfish (v4)?  RSS feed

Posts: 4
Java Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Community,

I stuck with a problem I can't find a solution to and I already tried to get help on stackoverflow ( but because nobody could help me there I would like to ask here too, maybe here are the experts that can point out what I am doing wrong.
I am using Servlets to provide a webservice to an android app. My problem is that I create two objects in my LogonServlet which I would like to restore in my other servlets:

What I am aiming to do:

I want to create different servlets. One of these is my LogonServlet which creates and Object which deals with RFCs to a SAP. This object I want to restore on my other servlets for the same session.

What I have done so far:

LogonServlet: (no real user authentification because I am still testing functionality)

The code of a different servlet to restore the session variables:

The problem is that it always returns "null" for the session.

This is my web.xml

I have no clue what I am doing wrong. It could be some setup I need to activate in glassfish v4 or something I have to do in the client that the server knows I would like to continue the session. This is my first project with javaEE, glassfish and servlets.

Thank you very much in advance.
Posts: 67197
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mentioned that your client is an Android app. You need to check if the Android services support cookies or not -- I have no idea. Cookies are the default means by which sessions are maintained across requests.

If not, and there's no way to enable that, you might look into URL re-writing.
Posts: 506
Java Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you tell me what this API is from : HttpServletStream hss = new GsonServletStream()
Villains always have antidotes. They're funny that way. Here's an antidote disquised as a tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!