Jsp can also use the for statement to loop the output content. The use of for and if makes the program flow more flexible.
To achieve the following results:
<% @ Page language = "java" import = "net. abjy. fts. util. *, java. SQL. *" pageEncoding = "UTF-8" %>
<% @ Include file = "/WEB-INF/manager/head. jsp" %>
<Link href = "style/style.css" rel = "stylesheet" type = "text/css">
<Link href = "style/lhgdialog.css" rel = "stylesheet" type = "text/css">
<Link href = "style/systemsetting.css" rel = "stylesheet" type = "text/css">
<%
String username = request. getParameter ("username ");
DataOperator db = new DataOperator ();
String SQL = "select * from" + username + "";
ResultSet r = db.exe cuteQuery (SQL );
%>
<DIV id = navbar> <UL> <LI> & nbsp; <a href = "content. action "> homepage </a> System Management> User Management> modify user information </LI> </UL> </DIV>
<FORM id = "update" name = "update" action = "" method = "post">
<TABLE class = ObjectRegisterPage>
<THEAD>
<TR> <TD colSpan = 2> </TD> </TR>
</THEAD>
<COLGROUP>
<COL style = "WIDTH: 50%">
<COL style = "WIDTH: 50%; TEXT-ALIGN: left">
</COLGROUP>
<TBODY>
<TR>
<TH> <FONT color = red> * </FONT> User Name (the user name cannot be modified): & nbsp; </TH>
<TD> & nbsp; <INPUT class = input_blue size = "15" value = "username" id = "username" name = "username" readonly = "readonly"> </TD>
</TR>
<%
While (r. next ()){
ResultSetMetaData data = r. getMetaData ();
%>
<%
For (int I = 1; I <= data. getColumnCount (); I ++ ){
String columnname = data. getColumnName (I );
String columnvalue = r. getString (I );
%>
<TR>
<TH> <FONT color = red> * </FONT> Field Names and values: <% = columnname %> & nbsp; </TH>
<TD> & nbsp; <INPUT type = "password" class = input_blue value = "<% = columnvalue %>" id = "userpas" name = "userpas"> </TD>
</TR>
<%
}
%>
<%
}
%>
<TR>
<TD class = table_button colSpan = 2>
<INPUT class = "Button_blue" onclick = "update. submit ();" type = button value = "modify"> & nbsp;
<INPUT class = "Button_blue" onclick = "location = 'user. action'" type = button value = "return">
</TD>
</TR>
</TBODY>
</TABLE>
<% @ Include file = "/WEB-INF/manager/footer. jsp" %>