Jsp for Loop

Source: Internet
Author: User

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" %>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.