• Post Reply Bookmark Topic Watch Topic
  • New Topic

error when I try to retrieve data stored in session variable  RSS feed

 
Arvind Chari
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am trying to implement openid based login for a web application. I am able to login succesfully, however for some reason, when I try and retrieve the session variable's data (for email id of user who logged on) I am not getting any text. I put in a if condition to check if the value is null (and then print on screen that it is a null value).

However for some reason only the title and first line of text are being printed on the page. Am I doing something wrong during initialisation of the session variable? Also, the flow is that from Login Page(HTML Form) the browser next goes to a Java page which processes the user id and password-- This java page sends the login data to Windows Live (or whatever OPENID provider was selected by user)-- Before this java page redirects to the Windows Live page, at that stage the session variable is stored. From Windows Live auth page the browser (on successful login) goes to the second page of my web application (This is a java page that denotes login successful)...I am not able to display the email ID of user, and what is surprising is that even the plain text "Email Address" is not getting printed on screen...I hope somebody can help figure out the problem here.

Kindly take a look at the code given below and tell me where I am doing it wrong-

CODE------------------------------------------------


//initialise the session object

HttpSession session = request.getSession(true);

// get the auth provider manager from session
SocialAuthManager manager = (SocialAuthManager)session.getAttribute("authManager");
// call connect method of manager which returns the provider object.
// Pass request parameter map while calling connect method.
Map<String, String> paramsMap = SocialAuthUtil.getRequestParametersMap(request);
AuthProvider provider = manager.connect(paramsMap);

// get profile
Profile p = provider.getUserProfile();
if(p.getEmail()==null)
out.println(" <br/><h4>Value of email ID is NULL??</h4><br/>");
else

// you can obtain profile information
out.println("<br/><br/><h4>Email Address: " + p.getEmail()+ "</h4><br/>");

----------------------END OF CODE



Thanks,
Arvind.
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to surround your code with braces. Something is causing the below statement not to execute at all. Also, you can reverse the if statement and see what happens.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bosun Bello wrote:Something is causing the below statement not to execute at all.


Like for example an exception being thrown. What happens if the variable "p" is null, for example? You could put it some more code which outputs debugging information at various places in that fragment if you want to see what's happening.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!