File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session problem in NetBeans

 
aymane chetibi
Ranch Hand
Posts: 175
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64180
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a servlet question, so moved to the JSP forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64180
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 175
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64180
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
session
 
aymane chetibi
Ranch Hand
Posts: 175
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did that but it's still giving me null.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64180
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 175
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64180
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means you've either not set the scoped variable, or you've set it to null.
 
aymane chetibi
Ranch Hand
Posts: 175
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64180
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this is specific to Netbeans, I've moved it to the IDEs forum with an appropriate title change.
 
aymane chetibi
Ranch Hand
Posts: 175
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry it works for both of them now.

thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic