...

View Full Version : Pass RecordSet to jsp



leonglass
06-22-2008, 03:56 PM
I have been looking around on this subject and the considered advice seems to be that I should not pass a RecordSet to my jsp page as I should close the connection as soon as possible. So I have gone on to try and process the information returned in the recordset and store it in a Vector and pass that to my jsp page for rendering. It doesn't work so my question is how should I be doing this?


...
while(rs.next())
{
users.add(new UserInfo(rs.getInt("uid"), rs.getString("name"), rs.getString("pass"), rs.getString("email")));
...
request.setAttribute("users", users);
}
From within the jsp file I can't seem to get the info back out of the users attribute at all but I have only been trying a for loop with an Enumeration. UserInfo is a class I have defined that just has the relevant constructor and public fields so I can access the members. Should I be looking at Beans for this?

The error I keep getting is "Enumeration cannot be resolved to a type"

for(Enumeration e = ${users}.elements(); e.hasMoreElements();)

brad211987
06-23-2008, 01:42 AM
Copy the error stack trace to here so we can look at it. It sounds like you just need to import the java.util.Enumeration package to wherever the error is being thrown. If that is the case, it can be done in the JSP page like this:

<&#37;@ page import="java.util.Enumeration"%>

leonglass
06-23-2008, 07:30 PM
Copy the error stack trace to here so we can look at it. It sounds like you just need to import the java.util.Enumeration package to wherever the error is being thrown. If that is the case, it can be done in the JSP page like this:

<%@ page import="java.util.Enumeration"%>No tried that and it didn't work but I think I have more or less sorted this out by reading through this sitepoint article (http://www.sitepoint.com/article/java-6-steps-mvc-web-apps). I had a few things wrong but I was pleased that I was trying to build it up in the same manner as the final app in that article. Thanks for your time anyway.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum