So that JSP page which outputs a list of users: presumably it didn't store all of them in the session? It's certain that it didn't store all of them in the session under the name of "user", since that can only refer to one object.
You should use this to get a User object somehow (don't ask me how, I know nothing about your system)
Does deleting a user require you to keep track of any other information which will be used in future requests?
Jay Tai wrote:User user = (User) session.getAttribute("users"), but this resulted in a typeCast error.
That means that the scoped variable is not a User instance. No amount of casting will make it one.
Jay you have reversed the sequence of the first lines in the servlet and you have added the httpsession that is not in the Murach servlet. The emailAddress string needs to be read before calling User with it.
Jay Tai wrote:"users" is not an instance of User because the "users" attribute is coming from another servlet (DisplayUsersServlet)? right?
And if you look at line 25, you can see where the users scoped variable is created, and it is not an instance of User
Jay Tai wrote:users is of type User?
SCJP
I"m getting this from a book (Java Servlets and JSPs by Murach to be exact). It's one of the first times i've seen a DB /JDBC app that doesn't use a numeric PK, but I'm reluctant to deviate from the example in the book at this point by creating a proper PK
Murach may have used a sketchy database design, but they would never be guilty of such a bad practice.
Consider Paul's rocket mass heater. |