在servlet里面如何存储单挑记录
String id = request.getParameter("id");
DBconnection dbc = new DBconnection();
ResultSet rs = dbc.getResultSet("select * from db1 where id="+id);
try {
rs.last();
rs.getRow();
System.out.println(rs.getString("name"));
employee employee1 = new employee();
employee1.setName("name");
response.sendRedirect("editemployee.jsp");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}在editemployee.jsp里面如何调用呢?

解决方案 »

  1.   

    1. URL传值response.sendRedirect("editemployee.jsp?id=" + id);
    editemployee.jsp中用String id = request.getParameter("id");取2.SESSION传值
    session.setAttribute("id", id);
    editemployee.jsp中用String id = (String)session.getAttribute("id");取
      

  2.   

    把对象存到session中,到jsp页面用el取
    try {
    rs.last();
    rs.getRow();
    System.out.println(rs.getString("name"));
    employee employee1 = new employee();
    employee1.setName("name");
    request.getSession().setAttribute("employee", employee1 );
    response.sendRedirect("editemployee.jsp");
    } catch (SQLException e) {jsp页面:
    ${employee.name}