package package11;
import java.sql.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class registration11 {
String name="fail";
String result=null;
public ActionForward execute(HttpServletRequest req,HttpServletResponse res,ActionMapping mapping,ActionForm form)
{
name=getresult();
return mapping.findForward(name);
}
protected String getresult()
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbc:oracle:thin:@localhost:1521:XP";
String username = "system";
String password = "sys";
Connection con = DriverManager.getConnection(url, username, password);
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select name from employee");
while(rs.next())
{
result=rs.getString("name");
}
HttpSession ses=request.getSession();
ses.setAttribute("customername",result);
name="success";
}
catch(Exception e)
{}
return name;
}
}
in the above code i use getAttribute(("customername") in my
jsp to get the value.. i ll be getting the result only once from the database.. but i ve more than 10 data in my "name" column ... what is the code to iterate and get all the 10 data in my jsp.. ?? please help me out... thanks in advance..