Tomcat servlet problem with session attribute

M

marco

A strange problem, I think...

I have a basic HTML form sending username and password to a servlet.
This servlet uses an external class to set up a DB connection, using
the username and the password to get the login access.
The HttpSession initialized on the first jsp is passed to the external
class such as a parameter in the constructor.
The external class istance (i.e., conn) execute the query to the DB,
and then returns to the servlet all the information.

As the results arrive to the servlet, the servlet itself sets up the
session attributes.
For example:

s.setAttribute("userId", conn.rs.getString("ID"));

My question is:

Why the command: s.getAttribute("userId") returns NULL?

Thank you.
 
J

josh.s17

Are you sure that conn.rs.getString("ID") is returning something.
Sounds pretty straightforward. Might help if you post your code.
 
M

marco

thank you so much, but I solved.

In fact, I was taking two times the same ResultSet, without doing the
BeforeFirst() the second time..... ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top