How does JSP fetch data from a database and display it on a table

Source: Internet
Author: User

<%@ page language = "java" contentType = "text/ html Charset=iso-8859-1 "

pageencoding="iso-8859-1"%>

<! DOCTYPE html public "-//w3c//dtd HTML 4.01 transitional//en " "/ http Www.w3.org/TR/html4/loose.dtd ">

<%@ page import="java.io.*,java.util.*,java.sql.*"%>

< Table Border="1" width="100%" >

< TR >

<TD width="60" valign="Top" bgcolor="#999999" class="DH"><Div Align="Center">name</Div></TD>

<td Width= " valign" ="Top">< Div Align="left">password<br>

        </ div ></ TD Span style= "COLOR: #009193" >>

< TD width = "9" valign = "top" > <!--dwlayoutemptycell-->&NBSP; </ TD >

</TR>

<%

Request.setcharacterencoding ("gb2312");

Java.sql.Connection conn = drivermanager.getconnection ("Jdbc:mysql://localhost:3306/gpsdatabase"," Root "," 123456 ");

String sql1="Select*from user_table";

Statement statemenet = (Statement) conn.createstatement ();

ResultSet rs1 = Statemenet.executequery (SQL1);

while (Rs1.next ()) {

%>

< TR >

<TD width=" the" valign="Top" bgcolor="#999999" class="DH"><Div Align="Center"><span class="Style8"><%=Rs1.getstring ("Email")%>"</span></Div></TD>

<TD width=" the" valign="Top"><Div Align="left"><span class="Style8"><%=Rs1.getstring ("Password")%></span><BR>

                        </ div ></ td >

                      < td width = "9" Span style= "COLOR: #932192" >valign = <!--dwlayoutemptycell--> </ TD >

</ TR >

<%

} rs1.close ();

%>

</table>


How does JSP fetch data from a database and display it on a table

Related Article

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.