java程序中检索的数据集怎么在JSP中显示出来.
JAVA文件
==========
public ActionForward execute(final ActionMapping mapping,
final ActionForm form, final HttpServletRequest request,
final HttpServletResponse response) throws Exception {
try {
if (form instanceof LoginForm) {
boolean is_user = false;
boolean is_psw = false;
LoginForm theForm = (LoginForm) form;
// SQL文を検索する
String str_userinfo_sql = "SELECT * FROM db2inst1.USER_INFO_LYS ";
// 新しい対象
ConnDb myconn = new ConnDb();
// 検索データベース
ResultSet result_user = myconn.execSql(str_userinfo_sql);
while (result_user.next()) {
if (theForm.getUsername().equals(result_user.getString( "USER_NAME ").trim())) {
is_user = true;
if (theForm.getPassword().equals(result_user.getString( "PASSWORD ").trim())) {
is_psw = true;
if (theForm.getUsername().equals( "test ")) {
return new ActionForward( "/admin.do ");
} else {
return new ActionForward( "/user.do ");
}
}
}
}
myconn.closeConnection();
if (is_user == false) {
return new ActionForward( "/error.do?msg=palece input another username ");
}
if (is_psw == false) {
return new ActionForward( "/error.do?msg=palece input another password ");
}
}
} catch (Exception e) {
}
return null;
}
=============================
ResultSet result_user = myconn.execSql(str_userinfo_sql);
检索的数据集 result_user 我现在在JSP页面怎么能调用到.
一定要用JavaBean的方式?谢谢!
[解决办法]
request.setAttribute( "list ",result_user);
页面
<%
List list = (List)session.getAttribute( "list ");
for (int i = 0; i < list.size(); i++) {
String display = (String)list.get(i);
%>
<html:option value= " <%= display%> "> <%= display%> </html:option>
<%
}
%>