Reputation: 6474
I have a scenario where I am trying to login a user to my database using a standard servlet... Now what I want to do is, after the login, the GWT created web page should open, and it should display the email ID of logged in user.
What I thought is I will redirect a successfully logged in user to a servlet, and that servlet will store the user's email id and some other parameters as session variables. And after this the page created using GWT on startup will read the user's email ID from the session variable..
I have a couple of questions about this approach...
One, is it secure? Is there some better way you can suggest of accomplishing user auth?
Two, how do I access the session variable from web page created using GWT? This variable should be accessed in this function--
public void onModuleLoad()
Or is the variable to be accessed from somewhere else in the web page?
I am using Google App Engine for Java/ GWT and Google Identity Toolkit (GIT) for authentication.
Upvotes: 0
Views: 1567
Reputation: 10285
the Session variables are not related to GWT, they are related to JAVA. If you want to use the session variables, you have to use them in the Server package of your GWT project.
Set a session variable:
session.setAttribute("MySessionVariable", 3);
Get a session variable
int param = (Integer) session.getAttribute("MySessionVariable");
Upvotes: 1
Reputation: 7985
the method onModuleLoad() is the startpoint of your client app written in gwt (which is essentially javascript)
So you are asking how can I read values from the server in Javascript.
This can be done in many ways in your GWT situation you could:
Upvotes: 2