Session Variable not Working

T

TManners

Ok I'm hoping someone can clarify and help me with this. Working in
JSP, I have a session variable that is giving me fits when I try to
get it and pass it to an Oracle stored procedure.

The session variable is an integer and was store like this on a login
page:

session.setAttribute("userid", new Integer(sRetVal));

This is the snippet of code for the page that is trying to use that
session variable:

Integer iUserid=(Integer)session.getValue("userid");
CallableStatement oCs = oCn.prepareCall("{CALL " + sSPName + "(?, ?,
?, ?)}");
oCs.setString(1, CleanPath);
oCs.setString(2, " ");
oCs.setInt(3, iUserid);
oCs.registerOutParameter(4, java.sql.Types.INTEGER);
oCs.setInt(4, 0);
oCs.execute();
int iRetVal=oCs.getInt(4);
out.print(iRetVal);

The problem is that I get an error when I try to set iUserid as the
3rd parameter in the stored procedure call. I can't figure out why. I
think I have tracked it down to being the recasting of the session
variable to Integer. Thoughts? I have a deadline I am trying to
meet.

-Tom
 
M

Murray

....
This is the snippet of code for the page that is trying to use that
session variable:

Integer iUserid=(Integer)session.getValue("userid");

This is unrelated to your question (joe gave the correct answer for that).
HttpSession#getValue() is deprecated now, you should be using getAttribute()
 

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,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top