Tomcat servlet problem with session attribute

Discussion in 'Java' started by marco, Mar 24, 2006.

  1. marco

    marco Guest

    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.
     
    marco, Mar 24, 2006
    #1
    1. Advertising

  2. marco

    Guest

    Are you sure that conn.rs.getString("ID") is returning something.
    Sounds pretty straightforward. Might help if you post your code.
     
    , Mar 24, 2006
    #2
    1. Advertising

  3. marco

    marco Guest

    thank you so much, but I solved.

    In fact, I was taking two times the same ResultSet, without doing the
    BeforeFirst() the second time..... ;)
     
    marco, Mar 24, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mladen Adamovic
    Replies:
    3
    Views:
    4,174
    Mladen Adamovic
    Nov 16, 2003
  2. Sean Clarke
    Replies:
    1
    Views:
    1,948
    Sudsy
    Jan 7, 2004
  3. circuit_breaker
    Replies:
    2
    Views:
    2,084
    Jack Jia
    Apr 4, 2004
  4. Doug McCann
    Replies:
    1
    Views:
    1,142
    William Brogden
    Aug 5, 2004
  5. Replies:
    0
    Views:
    890
Loading...

Share This Page