Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you store object in sessions? 1

Status
Not open for further replies.

pdotd

Programmer
Jun 15, 2004
29
0
0
CA
when programming in servlets, can you store objects in session?

pdotd
 
why not?

HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
request.setAttribute("page",rs.getString("count"));
String temp=request.getParameter("page");

Java is My Power
 
You can only store an Object in a session :)

--------------------------------------------------
Free Database Connection Pooling Software
 
Well the reason why i ask this question is because this is user class that holds a user name, user login, and user password,

so when i get the info to add a new user from the submitted form, in my servlet i just create a user object to input the user info from the form and then store the user object i just created into a session variable.

but my problem is that get an compile error message when i create a new user object in my doGet() method

here is my error:

AddStudent.java:32: cannot resolve symbol
symbol : class User
location: class webapp.AddUser
User one = new User();
^
AddStudent.java:32: cannot resolve symbol
symbol : class User
location: class webapp.AddUser
User one = new User();
^
2 errors


any would help if my error would be awesome, thank

pdotd


 
In what package is the User class located? And have you imported it.

Sjakie

----------
Yes, the world is full of strange people.
 
actaully i figured out what the was the problem
my classpath was not configured properly

thanks for the help though
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top