storing String or Int in Session Variable ?

M

mhk

Hi ,

i am working with JSP and getting error while using
"session.setAttribute("val",v)" , while v in int.

is there any other way to store String or Int in session variables in JSP.


Thanks

Jeff
 
J

Jose Rubio

If you check the HttpSession api document, you'll see that the setAttibute
method isgnature is like this:

void setAttribute(java.lang.String name, java.lang.Object value)

If you are using an int data type, you'll have to encapsulate inside an
Integer object first. So your statement would read:

session.setAttribute( "val", new Integer( v ) );

Hope it helps,

Jose
 

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

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top