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 7414493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:06:31+00:00 2026-05-29T07:06:31+00:00

I am new to gwt and I am creating a login page using gwt

  • 0

I am new to gwt and I am creating a login page using gwt and I need help with session managment.

All answers already given here, explains how to manage sessions on server side,
I need to use session on client side (browser’s session) exactly like with JSP files:
session.setAttribute("UserName", username);

Can any one provide a clear full example of how to implement this (Remember I am new to gwt).
I looked at this tutorial:
http://code.google.com/p/google-web-toolkit-incubator/wiki/LoginSecurityFAQ
And this doesn’t help me because it doesn’t explain how to use the browser’s session.

Thank you.

  • 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-29T07:06:31+00:00Added an answer on May 29, 2026 at 7:06 am

    “I need to use session on client side (browser’s session) exactly like with JSP files: session.setAttribute(“UserName”, username);”

    I wish to correct your misconception. The following is not browser side code and not browser side session. It is server side code, managing server-side session info.

    session.setAttribute("UserName", username);
    

    You would transmit this server-side session info to the client in your JSP, for example:

    <script>
    var username = "<%=username%>";
    </script>
    

    Or,

    <script>
    var username = '<%=session.getAttribute("UserName")%>';
    </script>
    

    As an experienced JSP programmer, you would realise the decoupling between the HTML/Javascript (generated by the JSP) and the JSP itself. And for the limitations you had faced with JSP is the reason why you are turning to GWT.

    The similarities between JSP generated client and GWT generated client

    • Occasionally (maybe frequently) programmers mistake server-side code as client-side code, vice versa. Just as you did.

    • Both generate javascript and HTML elements that is sent to the client to be executed.

    • Whatever you cannot do with javascript generated by JSP, similarly cannot be done by the GWT client-side Java source.

    • Whatever needs to be done by JSP generated client code, also needs to be done by GWT client code.

    • You can embed session information in the HTTP header, POST or GET parameters.

    • You need the client to maintain session info, mostly in the form of cookies.

    • Under certain circumstances, the jsessionid cookie is not set by server’s response.

    • Your servlet or its container could generate the http set-cookie header for JSESSIONID.

    • The servlet can control when the cookie header is created – due to request.getSession().

    .

    The difference between JSP generated client and GWT generated client

    • JSP generated client is refreshed per request/response. As such, you can transmit changes and data between client and server for every request/response.

    • GWT generated client is persistent to the client and not refreshed. It is for this reason that you are turning to GWT.

    • This refresh difference is very crucial in understanding the difference in coding for GWT than for JSP.

    • All the Java code in JSP is server-side code. In JSPs, there are no client-side code written in Java. Even the Java code used for generating the HTML/javascript is server-side code.

    • All client-side Java code is translated/compiled into Javascript. So the GWT Java code is actually “compiler-side” code.

    .

    Means of communication between client-server in GWT

    • Don’t forget to use the Dictionary class client side code to transmit your static settings to GWT app thro Javascript objects defined in the hosting file. You can set javascript objects as vars and they will be readable by the Dictionary class after the gwt module is loaded.

    • Don’t forget that you can use JSP to generate the GWT hosting file – so that you can create different behaviours afforded by different Dictionary readings that you can individualise for each invocation of your app.

    • However, you should not place the session id or authentication info on the hosting file. Because even though dynamically generated by JSP, it is actually static on the persistent GWT client.

    • You can use Window.Location.reload() to needlessly refresh you GWT client, just in case you still love the refresh effects of JSP.

    • GWT-RPC

    • RequestBuilder

    • RequestFactory

    • REST and REST-RPC

    • Script include (for crossing SLD-SOP boundaries)

    All client-server communication requires the GWT client to provide a callback, due to the asynchronicity of the technology.

    Take a look at http://google-web-toolkit.googlecode.com/svn/javadoc/2.4/com/google/gwt/http/client/RequestBuilder.html (Or view it at your personal copy of the GWT javadoc).

    … where you will be able to define set and get headers. Your server-side has to concur with the client what header name is used.

    You do not need to depend on the conventional JEE session to “maintain session”. You can contrive your own token framework. Or use an existing one, like OAuth or OpenId.

    Under various conditions, you will not get session cookie set in the server’s response.

    Under certain circumstances, you may need to abandon the use of conventional JEE sessions altogether when writing a GWT app.

    You should consider using REST or REST-RPC as I am attempting to document it (at a snail’s pace) in: http://h2g2java.blessedgeek.com/2011/11/gwt-with-jax-rs-aka-rpcrest-part-0.html.

    REST does not require you to maintain a session cookie. In my opinion, GWT works best with REST-RPC.

    You could browse over previous posts there, where there are explanation on other forms of client-server comms with GWT.

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

Sidebar

Related Questions

I am creating a application using gwt and hibernate.Here I am using code given
When I'm creating new project with GWT plug in it creates a skeleton project
I am new new to GWT. I have designed the Gui using GWT designer.
I'm new in using GWT. When I heard about GWT I thought than I
Im moving first steps today on GWT framework. I need to understand (using the
I am new to GWT and I am creating a web interface to show
At first I used the Grid. After creating a new version of the GWT,
When i create a new GWT (version 2.3) project using the Eclipse (version 3.5)
Does anyone have a working example of using the new GWT constructs for RequestFactory
I'm pretty new with EJB's and GWT but I've been using Java for a

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.