📄
字号:
范例User_updateext.jsp源代码:
001 <%@page contentType="text/html;charset=Gb2312"
002 import="Java.sql.*,Java.util.Date"%>
003 <JSP:useBean id="pool" scope="application" class="com.PoolBean"/>
004 <%
005 String strLoginUser = (String)session.getAttribute("LoginUser");
006 if (strLoginUser == null || strLoginUser.length() == 0)
007 response.sendRedirect("Login.jsp");
008 %>
009 <html>
010 <head>
011 <title><h1>用户信息修改</h1></title>
012 </head>
013 <body>
014 <%
015 String user_password,user_sex,user_birthday,user_year;
016 String user_month,user_day,user_duty,user_workplace;
017 String user_tel,user_address,user_email;
018 user_password = new
019 String( request.getParameter("user_password").getBytes("8859_1"));
020 user_sex = new
021 String( request.getParameter("user_sex").getBytes("8859_1"));
022 user_year = new
023 String( request.getParameter("user_year").getBytes("8859_1"));
024 user_month = new
025 String( request.getParameter("user_month").getBytes("8859_1"));
026 user_day = new
027 String( request.getParameter("user_day").getBytes("8859_1"));
028 user_duty = new
029 String( request.getParameter("user_duty").getBytes("8859_1"));
030 user_workplace = new
031 String( request.getParameter("user_workplace").getBytes("8859_1"));
032 user_address = new
033 String( request.getParameter("user_address").getBytes("8859_1"));
034 user_tel = new
035 String( request.getParameter("user_tel").getBytes("8859_1"));
036 user_email = new
037 String( request.getParameter("user_email").getBytes("8859_1"));
038 out.println(user_email);
039 user_birthday=user_year+"-"+user_month+"-"+user_day;
040 try
041 {
042 if (pool.getConnectionSize() == 0)
043 {
044 pool.initializePool();
045 }
046 Connection con = null;
047 Statement stmt = null;
048 con = pool.getConnection();
049 stmt= con.createStatement();
050
051 String strUpd ="update user set password='" + user_password + "',
052 sex='"+user_sex+"',birthday='"+user_birthday+"',
053 duty='"+user_duty+"',workplace='"+user_workplace+"',
054 address='"+user_address+"',telephone='"+user_tel+"',
055 email='"+user_email+"' where code='"+strLoginUser+"'";
056 //out.println(strUpd);
057 stmt.executeUpdate(strUpd);
058 stmt.close();//关闭Statement对象
059 pool.releaseConnection(con);
060 response.sendRedirect("Login.jsp");
061 }
062 catch (Exception e)
063 {
064 out.println(e.getMessage());
065 }
066 %>
067 </body>
068 </html>
范例User_delete.jsp源代码:
001 <%@page contentType="text/html;charset=Gb2312"
002 import="Java.sql.*,Java.util.Date"%>
003 <JSP:useBean id="pool" scope="application" class="com.PoolBean"/>
004 <%
005 String strLoginUser = (String)session.getAttribute("LoginUser");
006 if (strLoginUser == null || strLoginUser.length() == 0)
007 response.sendRedirect("Login.jsp");
008 %>
009 <html>
010 <head>
011 <title><h1>用户删除</h1></title>
012 </head>
013 <body>
014 <center>
015 <font size=5 color=blue></font>用户删除</font>
016 </center>
017 <hr>
018 <%
019 try
020 {
021 if (pool.getConnectionSize() == 0)
022 {
023 pool.initializePool();
024 }
025 Connection con = null;
026 Statement stmt = null;
027 con = pool.getConnection();
028 stmt= con.createStatement();
029 String strDel ="delete from user where code='"+strLoginUser+"'";
030 stmt.executeUpdate(strDel);
031 stmt.close();//关闭Statement对象
032 pool.releaseConnection(con);
033 response.sendRedirect("Login.jsp");
034 }
035 catch (Exception e)
036 {
037 out.println(e.getMessage());
038 }
039 %>
040 </body>
041 </html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -