Hi,
THere are a few things you have to do..
First requestURI should point to your url not the example url.
Second the scope is session while you are setting the object in request.
Regards
Rajesh J
To: [EMAIL PROTECTED]
"Srikanth Gubba" <[EMAIL PROTECTED]> cc:
Sent by: Subject:
[displaytag-user] display tag with struts action forms
[EMAIL PROTECTED]
net
28 Mar 2003 09:25 AM
hi ,
i am using display tag in jsp /struts with arraylist in action forms , but i
am getting the error
=----I do not know how to iterate over 'class java.lang.String'
i am using the following display code
<display:table width="85%" list="employees" scope="session"
pagesize="2"
requestURI="
http://edhill.its.uiowa.edu/display-examples-0.8.5/example-paging.jsp">
<display:column property="name" sort="true" />
<display:column property="email" />
<display:setProperty name="sort.behavior" value="list" />
<display:setProperty name="paging.banner.include_first_last"
value="true" />
</display:table>
and my action form code is
package com.wiley;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionError;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.ArrayList;
public class EmployeeListAction extends Action {
protected ArrayList getEmployees() {
Employee employee = null;
ArrayList employees = new ArrayList();
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
ServletContext context = servlet.getServletContext();
DataSource dataSource = (DataSource)
context.getAttribute(Action.DATA_SOURCE_KEY);
try {
conn = dataSource.getConnection();
stmt = conn.createStatement();
rs =
stmt.executeQuery("select * from employees, roles, "
+ "department where employees.roleid=roles.roleid "
+ "and employees.depid=department.depid");
while ( rs.next() ) {
employee = new Employee();
employee.setUsername(rs.getString("username"));
employee.setName(rs.getString("name"));
employee.setRolename(rs.getString("rolename"));
employee.setPhone(rs.getString("phone"));
employee.setEmail(rs.getString("email"));
employee.setRoleid(new Integer(rs.getInt("roleid")));
employee.setDepid(new Integer(rs.getInt("depid")));
employee.setDepartment(rs.getString("depname"));
employees.add(employee);
System.err.println("Username : "
+ employee.getUsername()
+ " Department : " + rs.getString("depname"));
}
}
catch (SQLException e) {
System.err.println(e.getMessage());
}
finally {
if (rs != null) {
try {
rs.close();
}
catch (SQLException sqle) {
System.err.println(sqle.getMessage());
}
rs = null;
}
if (stmt != null) {
try {
stmt.close();
}
catch (SQLException sqle) {
System.err.println(sqle.getMessage());
}
stmt = null;
}
if (conn != null) {
try {
conn.close();
}
catch (SQLException sqle) {
System.err.println(sqle.getMessage());
}
conn = null;
}
}
return employees;
}
public ActionForward perform(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Default target to success
String target = new String("success");
EmployeesActionMapping employeesMapping =
(EmployeesActionMapping)mapping;
// Does this action require the user to login
if ( employeesMapping.isLoginRequired() ) {
HttpSession session = request.getSession();
if ( session.getAttribute("USER") == null ) {
// The user is not logged in
target = new String("login");
ActionErrors errors = new ActionErrors();
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError("errors.login.required"));
// Report any errors we have discovered back to
// the original form
if (!errors.empty()) {
saveErrors(request, errors);
}
}
}
ArrayList employees = null;
employees = getEmployees();
// Set the target to failure
if ( employees == null ) {
target = new String("login");
}
else {
request.setAttribute("employees", employees);
}
// Forward to the appropriate View
return (mapping.findForward(target));
}
}
please help me with the error.
thanks in adv.
sri.
_________________________________________________________________
High ISD bills? Get a phone card. http://www.msn.co.in/webtelephony Call US
for just Rs. 5
-------------------------------------------------------
This SF.net email is sponsored by:
The Definitive IT and Networking Event. Be There!
NetWorld+Interop Las Vegas 2003 -- Register today!
http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
_______________________________________________
displaytag-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/displaytag-user
-------------------------------------------------------
This SF.net email is sponsored by:
The Definitive IT and Networking Event. Be There!
NetWorld+Interop Las Vegas 2003 -- Register today!
http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en
_______________________________________________
displaytag-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/displaytag-user