• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error when I try to retrieve data stored in session variable

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic