Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7054303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:36:36+00:00 2026-05-28T03:36:36+00:00

I have a GWT application that has RPC service on its back end. I’m

  • 0

I have a GWT application that has RPC service on its back end. I’m currently trying to implement users support and the only question that still remains is the way I should store session data.

I’m storing session id using

getThreadLocalRequest().getSession().setAttribute("sid", "randomSIDgoeshere");

So, the first question is more to Java servlets than to GWT. Does this code guarantee that next time I make a call like this:

getThreadLocalRequest().getSession().getAttribute("sid");

It would either be null (in case it gets called for the user that hasn’t yet visited the piece of code where SID attribute is set) or it would exactly the same SID I’ve already save for that user. In other words, are these 2 pieces of code user-specific? (by user I mean single browser on a single computer)

The second question is about storing the mappings between SIDs and some extra data like user id. In case I have a code like this:

public class MyGwtServiceImpl extends RemoteServiceServlet implements MyGwtService {
  // SID to User ID mappings
  private final Map<String, String> sessions = 
    new HashMap<String, String>();
  ...
}

Is it guaranteed that sessions is always the same object for all requests and its data will remain “alive” unless the whole application is terminated? (Tomcat is stopped for instance) Is it normal approach or I should persist all these mappings on my DB?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:36:37+00:00Added an answer on May 28, 2026 at 3:36 am

    First:

    Yes, it does guarantee. The next time you call getThreadLocalRequest().getSession().getAttribute("sid"); on the next request, the attribute sid will stay there. But remember, that’s the local request area, thus only requests from the same user (browser + ip) shall share the information. That means:

    Fact:

    • User A connects with Firefox
    • You store a random value X with the ID Y

    Case 1

    • User A connects with Firefox
    • You can retrieve the X

    Case 2

    • User A connects with Google Chrome
    • You cannot retrieve the value X

    Case 3

    • User B connects with Firefox
    • You cannot retrieve the value X

    So yes, the session’s content is user-specific. What exists in one session does not imply that will exist in other session.

    Second:

    No, it is not guaranteed. Although most of the times the same servelet isntance will be called, it is not guaranteed that will always exist. If you want to persist with attributes in your servelet, you must declare those attributes as Static, and by so, THAT static attribute won’t be user-specific. Or you can store in the ServeletContext

    I say this because different implementations (like Glassfish) can terminate instances if the servelet isn’t being required for a long period of time (as far as I remember, I’m not sure of this (Glassfish terminating the instance)). But there is no documentation saying that it does guarantee that will be the same instance, so you cannot declare non-static attributes and share between diferent instances.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an AWT applet application that needs to be ported over to GWT.
I have a GWT app that makes an RPC call to a server to
We have a GWT application that needs to display various holidays. Is there a
I have googled some time now trying to find a good sample application that
My application has some features that are accessible to all users, and some other
I have an application that uses gwt-dnd to make boxes draggable, but when there
I have a view that I created in my GWT application and I would
How to achieve multipage with GWT, such that the gwt application can have multiple
I'm coding a web application in GWT. I have a class that handles all
I have been trying to create a simple application that will let the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.