标签:style blog http io color ar os sp java
登录(指定登录号密码的简单判断):
1 <%@ page language="java" import="java.sql.*" pageEncoding="gb2312"%> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 5 <title>登录</title> 6 </head> 7 <script type="text/javascript"> 8 function check()// JavaScript Document 9 { 10 var flag = true; 11 if (document.form.no.value == "") { 12 alert("用户名或密码不能为空"); 13 form.no.focus(); 14 flag = false; 15 } else if (document.form.psw.value == "") { 16 alert("用户名或密码不能为空"); 17 form.psw.focus(); 18 flag = false; 19 } 20 if (flag) { 21 document.form.submit(); 22 } 23 } 24 </script> 25 <style type="text/css"> 26 body { 27 background-repeat: no-repeat; 28 background-attachment: fixed; 29 background-position: center; 30 text-align: center; 31 margin: 0px auto; 32 } 33 34 div { 35 left: 80%; 36 margin-left: -530px; 37 position: absolute; 38 } 39 </style> 40 <body background="images\1.jpeg"> 41 <br> 42 <br> 43 <br> 44 <br> 45 <br> 46 <br> 47 <br> 48 <br> 49 <br> 50 <br> 51 <br> 52 <br> 53 <div> 54 <font face="华文新魏">登录图书管理系统</font> 55 <p> 56 <form name="form" method="post" action="judge.jsp" align="center"> 57 <table width="256" border="1"> 58 <tr> 59 <td width="68" height="43"><font color="#003399">登录号:</font></td> 60 <td><input type="text" name="no"></td> 61 </tr> 62 <tr> 63 <td height="43"><font color="#003399">密码:</font></td> 64 <td><input type="password" name="psw"></td> 65 </tr> 66 </table> 67 <br /> <input type="button" value="登录" onClick="check()" 68 style="width: 130px;" /> 69 </form> 70 </div> 71 </body> 72 </html>
judge.jsp
首页:
<%@ page language="java" import="java.sql.*" pageEncoding="gb2312"%> <html> <head> <title>图书管理系统</title> </head> <body bgcolor="#FFA500"> <br> <br> <br> <br> <br> <br> <br> <br> <center> <div> <img src="images\2.jpeg" width=80%> </tr> </div> <div> <table align="center" width="80%" border=1 bgcolor="#3CC4C4"> <tr> <th>书号</th> <th>书名</th> <th>作者</th> <th>出版社</th> <th>操作</th> </tr> <% Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.142.129:1521:orcl2","system","orcl"); Statement stmt=con.createStatement(); String s="select * from Book"; ResultSet rs=stmt.executeQuery(s); while(rs.next()) { String bno=rs.getString(1); out.println("<tr><td>"+rs.getString(1)+"</td><td>《"+rs.getString(2)+"》</td><td>"+rs.getString(3)+"</td><td>"+rs.getString(4)+"</td><td><a href=‘edit.jsp?bno="+bno+"‘>修改</a> <a href=‘del.jsp?bno="+bno+"‘>删除</a></td></tr>"); } rs.close(); stmt.close(); con.close(); %> </table> </div> <br> <br> <table width="80%" bgcolor="#3CC4C4"> <tr> <a href=add.jsp><font face="华文新魏" style="font-size: 20px" >添加图书信息</font></a> ******** <a href=select.jsp><font face="华文新魏" style="font-size: 20px" >按条件查询</font></a> </tr> </table> </body> </html>
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" pageEncoding="gb2312"%> <html> <head> <title>删除图书</title> </head> <body bgcolor="#EEEE00"> <% request.setCharacterEncoding("gb2312"); Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.142.129:1521:orcl2","system","orcl"); Statement stmt=con.createStatement(); String bno=request.getParameter("bno"); int i=stmt.executeUpdate("delete from Book where bno=‘"+bno+"‘"); if(i==1) {out.println("<script language=‘javaScript‘> alert(‘删除成功,点击确定后自动跳到主页!‘);</script>"); response.setHeader("refresh","1;url=index.jsp"); } else{ out.println("<script language=‘javaScript‘> alert(‘删除失败,点击确定后自动跳到主页!‘);</script>"); response.setHeader("refresh","1;url=index.jsp"); } con.close(); stmt.close(); %> </body> </html>
修改:
<%@ page language="java" import="java.sql.*" pageEncoding="gb2312"%> <html> <head> <title>修改图书信息</title> </head> <style type="text/css"> body { background-repeat: no-repeat; background-attachment: fixed; background-position: center; text-align: center; margin: 0px auto; } </style> <body bgcolor="#FFA500" background="images\3.jpg"> <% request.setCharacterEncoding("gb2312"); Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.142.129:1521:orcl2","system","orcl"); Statement stmt=con.createStatement(); String bno=request.getParameter("bno"); String s="select * from Book where bno=‘"+bno+"‘"; ResultSet rs=stmt.executeQuery(s); rs.next(); %> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <form action="update.jsp" method="post"> <table align="center" width="30%" border="1"> <caption> <font face="华文新魏">修改图书信息</font> </caption> <tr> <th width="30%">书号:</th> <td width="70%"><input name="bno" type="text" value="<%=rs.getString(1)%>" readonly="readonly">不可更改</td> </tr> <tr> <th>书名:</th> <td><input name="name" type="text" value="<%=rs.getString(2)%>">*</td> </tr> <tr> <th>作者:</th> <td><input name="author" type="text" value="<%=rs.getString(3)%>"></td> </tr> <tr> <th>出版社:</th> <td><input name="publisher" type="text" value="<%=rs.getString(4)%>"></td> </tr> <tr> <th colspan="2"><input type="hidden" name="bno" value="<%=bno%>"> <input type="submit" value="修改" style="width: 50px;"> <input type="reset" value="重置" style="width: 50px;"> <a href=index.jsp> 返回</a></th> </tr> </table> </form> <% rs.close(); stmt.close(); con.close(); %> </body> </html>
<%@ page language="java" import="java.sql.*" pageEncoding="gb2312"%> <html> <head> <title>修改完成</title> </head> <body> <% request.setCharacterEncoding("gb2312"); Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.142.129:1521:orcl2","system","orcl"); Statement stmt=con.createStatement(); String sql="update Book set bno=‘"+request.getParameter("bno")+"‘,name=‘"+request.getParameter("name")+"‘,author=‘"+request.getParameter("author")+"‘,publisher=‘"+request.getParameter("publisher")+"‘ where bno=‘"+request.getParameter("bno")+"‘"; System.out.println(sql); int i=stmt.executeUpdate(sql); if(i==1) {out.println("<script language=‘javaScript‘> alert(‘修改成功,点击确定后自动跳到主页。‘);</script>"); response.setHeader("refresh","1;url=index.jsp"); } else{ out.println("<script language=‘javaScript‘> alert(‘修改失败,点击确定返回主页!‘);</script>"); response.setHeader("refresh","1;url=index.jsp"); } stmt.close(); con.close(); %> </body> </html>
添加:
<%@ page contentType="text/html; charset=gb2312" import="java.sql.*"%> <html> <head> <title>添加图书信息</title> </head> <style type="text/css"> body { background-repeat: no-repeat; background-attachment: fixed; background-position: center; text-align: center; margin: 0px auto; } </style> <body bgcolor="#EEEE00" background="images\3.jpg"> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <form action="add.jsp" method="post"> <div align="center"></div> <table align="center" width="30%" border="1"> <caption> <font face="华文新魏">添加信息</font> </caption> <tr> <th width="30%">书号:</th> <td width="30%"><input name="bno" type="text">*</td> </tr> <tr> <th>书名:</th> <td><input name="name" type="text">*</td> </tr> <tr> <th>作者:</th> <td><input name="author" type="text"></td> </tr> <tr> <th>出版社:</th> <td><input name="publisher" type="text"></td> </tr> <tr> <th colspan="2"><input type="submit" name="submit" value="添加" style="width: 50px;"> <input type="reset" value="重置" style="width: 50px;"> <a href=index.jsp> 返回</a></th> </tr> </table> </form> <% request.setCharacterEncoding("gb2312"); String submit=request.getParameter("submit"); if(submit!=null&&!submit.equals("")) { String name=request.getParameter("name"); String author=request.getParameter("author"); String publisher=request.getParameter("publisher"); String bno=request.getParameter("bno"); if(bno!=""&&name!="") { if(bno.length()<8 && name.length()<20 && author.length()<20 && publisher.length()<20) { Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.142.129:1521:orcl2","system","orcl"); Statement stmt=con.createStatement(); String sql="insert into Book(bno,name,author,publisher) values(‘"+bno+"‘,‘"+name+"‘,‘"+author+"‘,‘"+publisher+"‘)"; int i=stmt.executeUpdate(sql); if(i==1) { out.println("<script language=‘javaScript‘> alert(‘添加成功‘);</script>"); } else { out.println("<script language=‘javaScript‘> alert(‘添加失败,点击确定返回添加页面!‘);</script>"); response.setHeader("refresh","1;url=add.jsp"); } stmt.close(); con.close(); } else { out.println("<script language=‘javaScript‘> alert(‘添加失败,请确保正确填写!‘);</script>"); response.setHeader("refresh","1;url=add.jsp"); } } else { out.println("<script language=‘javaScript‘> alert(‘添加失败,请将带*的信息填写完整!‘);</script>"); response.setHeader("refresh","1;url=add.jsp"); } } %> </body> </html>
标签:style blog http io color ar os sp java
原文地址:http://www.cnblogs.com/candy-yyn/p/4099147.html