wood burning stoves 2.0*
The moose likes IDEs, Version Control and other tools and the fly likes Session problem in NetBeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Session problem in NetBeans" Watch "Session problem in NetBeans" New topic
Author

Session problem in NetBeans

aymane chetibi
Ranch Hand

Joined: Apr 12, 2006
Posts: 175
Deal all,

I am developping an application in which I want to keep track of user information in a session.

once the users logs in,the login servlet is invoked and I do the following:

than I get some information to the database and I dispatch to the main JSP.
in which I want to display for example "hello username, "

I did the following but it does not work:


it returns null.

Please help.
Regards,
[ May 13, 2006: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61450
    
  67

Not a servlet question, so moved to the JSP forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61450
    
  67



Imagine a very loud and annoying alarm klaxon going off!

Not only is this completely unnecessary -- since the session is already available to a JSP page via the session implicit variable -- by declaring the code in a declaration scriptlet you have introduced thread-safety issues into your page that will result in visitors to your page accessing the session of other visitors.

While that may result in new and exciting behavior for your application, I'm fairly certain that no one craves that particular type of excitement.
[ May 13, 2006: Message edited by: Bear Bibeault ]
aymane chetibi
Ranch Hand

Joined: Apr 12, 2006
Posts: 175
available to a JSP page via the session implicit variable


Can you please tell me how can I get access to this variable ??

thank you
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61450
    
  67

session
aymane chetibi
Ranch Hand

Joined: Apr 12, 2006
Posts: 175
I did that but it's still giving me null.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61450
    
  67

Are you saying that the session implicit variable is null? Hard to believe.

If you're talking about the result of getting the scoped variable from it, then you are probably not setting the variable into the session correctly.
aymane chetibi
Ranch Hand

Joined: Apr 12, 2006
Posts: 175
It's not the session implicit variable that is null, but getting the value from it: session.getAttribute("user");

I am setting in the Servlet that dispatches to the JSP that incurres the error like this:


Do you have idea why when I do this (String) session.getAttribute("user") in the JSP it gives null ?

Thank you.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61450
    
  67

It means you've either not set the scoped variable, or you've set it to null.
aymane chetibi
Ranch Hand

Joined: Apr 12, 2006
Posts: 175
No. I think the problem comes from the web container.
I run it on Tomcat and it runs fine.
But when I do it on NetBeans IDE it doesn't work.


regards,
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61450
    
  67

Since this is specific to Netbeans, I've moved it to the IDEs forum with an appropriate title change.
aymane chetibi
Ranch Hand

Joined: Apr 12, 2006
Posts: 175
Sorry it works for both of them now.

thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session problem in NetBeans