This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Error in struts program  RSS feed

Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using jsdk 1.5?
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!