File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Error in struts program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Error in struts program" Watch "Error in struts program" New topic

Error in struts program

Ram Kumar Rengarajan

Joined: Apr 28, 2005
Posts: 22
I have got an error in the following error in the below program: cannot find symbol
symbol : method setAttribute(java.lang.String,java.util.ArrayList)
location: interface javax.servlet.http.HttpServletRequest
request.setAttribute("users", list);
Note: uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

package strutsTutorial;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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 java.util.*;

import java.sql.Connection;
import javax.sql.DataSource;
import java.sql.PreparedStatement;
import java.sql.*;

public class DisplayAllUsersAction extends Action
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception



DataSource dataSource = getDataSource(request, "userDB");

Connection conn = dataSource.getConnection();
Statement statement = conn.createStatement();

ResultSet rs = statement.executeQuery("select FIRST_NAME, LAST_NAME, EMAIL from USER2");
ArrayList list = new ArrayList();
String firstName = rs.getString(1);
String lastName = rs.getString(2);
String email = rs.getString(3);
User user = new User();
if (list.size() > 0)
request.setAttribute("users", list);
catch(Exception e)

return mapping.findForward("success");

//return mapping.findForward("success");

Can anyone help me in this regard?

Ram Kumar.
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
Are you using jsdk 1.5?

I think, therefore I exist -- Rene Descartes
I agree. Here's the link:
subject: Error in struts program
It's not a secret anymore!