<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>修改个人信息</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->  </head>
  
  <body bgcolor="#FFCCCC">
  <% 
  String name=(String)session.getValue("name");
  if(name==null||name=="")
  {%>
  <p>你还没有登录</p>
  <p><a href="index.jsp">回到首页</a>
  <%} %>
  </p>
  <form action="edit1.jsp" method="post">
  <div align="center">
  <p>
  <%
  Connection Con=null;
 //加载数据库驱动类
Class.forName("com.mysql.jdbc.Driver").newInstance();
//数据库连接URL
String   url   = "jdbc:mysql://localhost:3306/test?useUincode=true&characterEncoding=gbk";
//数据库用户名,密码.
Con=DriverManager.getConnection(url,"root","1314");
Statement stat=Con.createStatement();
//生成查询的sql命令
String sql="select * from user where username='"+name+"'";
//rs 为返回结果的ResultSet对象
ResultSet rs=stat.executeQuery(sql);
rs.next();
String username = rs.getString("username");
String sex = rs.getString("sex");
String password = rs.getString("password");
String repassword = rs.getString("repassword");
%>   
请按照下表修改你的信息!</p><table width="200" border="1">
  <tr>
    <td align="right"> 用户名:
</td>
    <td align="left"><%=username%></td>
    <input type="hidden" name="username" value="<%=username%>">
  </tr> 
 <tr>
    <td  align="right">
     请设定您的密码:
     </td>
    <td  align="left"> 
    <input type="password" name="password" value="<%=password%>" /></td>
  </tr>
<tr>
    <td align="right"> 
    请确认您的密码:
    </td>
    <td align="left"> <input type="password" name="repassword" value="<%=repassword%>"/>
    </td>
  </tr>
<tr>
    <td align="right"> 请选择您的性别:</td>
    <td align="left"> 
    <input type="radio" name="sex"<%if(sex.compareTo("male")==0)
    out.print("checkd"); %>
     value="male" />男
    <input type="radio" name="sex"<%if(sex.compareTo("female")==0)
    out.print("checkd"); %>
     value="female" />女
   </td>
  </tr>
 <tr>
    <td align="right">职业:
    </td>
    <td align="left" >
    <select size="1" name="work">
    <option selected="selected">学生</option>
    <option> 公务员</option>
    <option>老师</option>
    <option>工人</optiion>
    <option>其它</option>
    </select>
    </td>
  </tr>
 <tr>
    <td align="right">运动爱好:</td>
    <td align="left"><input name="love" type="checkbox" value="篮球" />篮球
    <input name="love" type="checkbox" value="羽毛球" />羽毛球
    <input name="love" type="checkbox" value="足球" />足球
    <input name="love" type="checkbox" value="网球" />网球
    <input name="love" type="checkbox" value="兵乓球" />兵乓球
    <input name="love" type="checkbox" value="键子" />键子

</td>
  </tr>
<tr>
    <td align="right">个人说明:
    </td>
    <td align="left"><textarea name="show" cols="25" rows="15"></textarea></td>
  </tr>
   <tr>
 <td align="right">
<input name="" type="submit" value="提交" /> </td>
    <td align="left"> <input type="reset" value="重置" /></td>
  </tr>
   </table>  
   </div>
   </form> 
  </body>
</html>
edit1.jsp:
<%@ page language="java" contentType="text/html; charset=gb2312"
 %> <%@ page import = "java.sql.*" %>
 <%request.setCharacterEncoding("GBK"); %>
 <html>
<head>
<title>注册验证页面</title>
</head>
<body> <jsp:useBean id="g" class="beans.DBUtil" scope="page" />   
<% 
//加载数据库驱动类
Class.forName("com.mysql.jdbc.Driver").newInstance();
//数据库连接URL
String   url   = "jdbc:mysql://localhost:3306/test?useUincode=true&characterEncoding=gbk";
//数据库用户名,密码.
Connection conn=DriverManager.getConnection(url,"root","1314");
Statement stmt = conn.createStatement();
 String name = (String)request.getParameter("username");
String password = (String)request.getParameter("password");
String repassword = (String)request.getParameter("repassword");
String sex = (String)request.getParameter("sex");
String work = (String)request.getParameter("work");
String[] love = (String[])request.getParameterValues("love");
String show = (String)request.getParameter("show");
String strlove = "";
for(int i=0;i<love.length;i++){
if(strlove.trim().equals("")){
strlove = strlove+"'"+love[i].toString()+"'";
}
else{
strlove = strlove+",'"+love[i].toString()+"'";
}

if(strlove.trim().substring(0,strlove.trim().length()).equals(",")){
strlove = strlove.trim().substring(0,strlove.trim().length()-1);
}  
String sql="update user  set password ='"+password+"',repassword='"+repassword+"',sex='"+sex+"',work='"+work+"',strlove='"+love+"',shows='"+show+"'where username='"+name+"'";
stmt.executeUpdate(sql);
response.setHeader("refresh","3;url=liuyan.jsp");
%>
<p>修改成功</p>
  </body>
</html>