• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

sample user info page not working

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to know outside the forum if the user is logged :



Even if I'm logged I always get "User not logged! ".

Any clues?


[originally posted on jforum.net by boaglio]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this page in the same servlet context as the JForum software or in another web application?
[originally posted on jforum.net by GreenEyed]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Same context.
[originally posted on jforum.net by boaglio]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried checking all the names of the attributes stored in the session?

A simple iterator over session.getAttributeNames() would do.

It might be that "request.getSession().getId()" is not the name under which the UserSession object has been stored.

[originally posted on jforum.net by GreenEyed]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, it looks like Jforum handles the autoLogin stuff with cookies.

I've read this topic about jforumUserId,jforumAutoLogin and jforumUserHash.

Even though I read those cookies, how should I use Jforum functions to validate it ?

I wish I could use a taglib for it (maybe I will code one).
[originally posted on jforum.net by boaglio]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JForum does not put UserSession in the http session context, but inside its own cache. So, if you want to access the UserSession object, you should use the classe SessionFacade (net.jforum.SessionFacade)

On the other hand, if what you want is to just check if the user is logged, just look for the "logged" attribute:



Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great Rafael,

Your sample code worked fine!

I just need the user name and his jforum ID to integrate with my website.

From jforumUserId cookie, I could get the ID.

For the user name, i tried that:



But I get a NPE:



What should I do now? :lol:
[originally posted on jforum.net by boaglio]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, the missing thread local. In your request, do this:



then execute your code as usually, and, in the end, make sure the following code is called:




I suggest to put all inside a try-finally block, otherwise (if you don't set the threadlocal to null), you'll have problems.

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I tried that:



And I got this error:



[originally posted on jforum.net by boaglio]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like you're trying to use JForum's stuff before initializing the servlet

Rafael
[originally posted on jforum.net by Rafael Steil]
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic