📄 shoppinglist.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" import="java.io.*" import="javax.servlet.http.*" errorPage="" %>
<%@ page session="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<p>Welcome,
<%!String name="";%>
<%name = (String)session.getAttribute("sessionname");%>
<%=name%>
This is your shopping list:
<br>
<p><br>
<%
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");// .microsoft.jdbc.sqlServer.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs","sa","");
Statement st=conn.createStatement();
st.setMaxRows(20);
String sqlStr = "select * from film where username='"+name+"'";
ResultSet rs=st.executeQuery(sqlStr);
while(rs.next())
{
%>
<table width="300" border="1">
<tr>
<th scope="col" width="100">片名</th>
<th scope="col" width="100">价格</th>
<th scope="col" width="100">数量</th>
</tr>
</table>
<p>
<table width="300" border="1">
<tr>
<th scope="col" width="100"><%=rs.getString("filmname")%></th>
<th scope="col" width="100"><%=rs.getString("price")%></th>
<th scope="col" width="100"><%=rs.getString("quantity")%></th>
</tr>
</table>
<%}
rs.close();
st.close();
conn.close();}
catch(SQLException sqle){
sqle.printStackTrace();
}
catch(Exception ex){
ex.printStackTrace();
}%>
</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -