2007-02-05 11:00
  
	    2007-02-05 11:04
  
	    2007-02-05 11:09
  
	    2007-02-05 14:38
  
	    2007-02-06 08:54
  
	    2007-02-06 09:32
  <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>公司管理系统</title>
<style type="text/css">
<!--
body {
    background-image: url(image/bj.gif);
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
.style2 {color: #0033FF}
-->
</style></head>
<body>
<%
    request.setCharacterEncoding("gb2312");
    request.getSession(true);
    String name=new String(request.getParameter("user").getBytes("ISO8859_1"),"GBK");
    
    String password=new String(request.getParameter("pass").getBytes("ISO8859_1"),"GBK");
    
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String url="jdbc:odbc:mydata";
    String username="";
    String pass="";
    Connection con=DriverManager.getConnection(url,username,pass);
    Statement stmt=con.createStatement();
    String sql="select * from wglperson  where username='"+name+"'and password='"+password+"'";
    ResultSet rs=stmt.executeQuery(sql);
   if (rs.next())
      {
       int web=rs.getInt("web");
       String personid=rs.getString("username");
       session.setAttribute("personid",personid);
       if (web==1)
        {
%>
<table width="800" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td>
    <table width="800"  border="0"align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="6"><img src="image/top2.gif" width="800" height="58"></td>
  </tr>
  <tr>
    <td width="165" height="22"><img src="image/nav1.gif" width="165" height="22"></td>
    <td colspan="5" bgcolor="#CCCCCC"><img src="image/top2.gif" width="635" height="22"></td>
  </tr>
  <tr>
    <td colspan="6"><img src="image/spl_1.gif" width="76" height="72"><img src="image/top2.gif" width="724" height="72"></td>
  </tr>
<tr><td colspan="6"> <h3 align="center" class="style2">欢迎进入管理员界面</h3></td></tr>
<tr>
<td height="340"><img src="image/separator.gif" width="2" height="340"></td>
<td width="95">dfd</td>
<td width="127"><div align="right">dfd</div></td>
<td width="113">dfd</td>
<td width="100">dfd</td>
<td width="200"><div align="right"><img src="image/separator.gif" width="2" height="340"></div></td>
</tr>
<tr>
<td>dfd</td>
<td width="95">dfd</td>
<td width="127">dfd</td>
<td width="113">dfd</td>
<td width="100">dfd</td>
<td width="200">dfd</td>
</tr>
<tr>
<td>dfd</td>
<td width="95">dfd</td>
<td width="127">dfd</td>
<td width="113">dfd</td>
<td width="100">dfd</td>
<td width="200">dfd</td>
</tr>
<tr>
<td colspan="6"><img src="image/top2.gif" width="800" height="58"></td>
</tr>
<%}
if (web==2)
{
%>
 
 </table>
     <table width="800" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td>
    <table width="800"  border="0"align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="6"><img src="image/top2.gif" width="800" height="58"></td>
  </tr>
  <tr>
    <td width="165" height="22"><img src="image/nav1.gif" width="165" height="22"></td>
    <td colspan="5" bgcolor="#CCCCCC"><img src="image/top2.gif" width="635" height="22"></td>
  </tr>
  <tr>
    <td colspan="6"><img src="image/spl_1.gif" width="76" height="72"><img src="image/top2.gif" width="724" height="72"></td>
  </tr>
  <tr>
    <td>
     
   </td>
    <td colspan="4"><p align="center"><font size="+3" color="#0033FF" >欢迎光临领导用户界面</font></p></td>
    <td width="139"> </td>
  </tr>
  <tr>
    <td height="400"><img src="image/separator.gif" width="2" height="400"></td>
    <td width="149"> </td>
    <td width="133"></td>
    <td width="156"> </td>
    <td width="76"> </td>
    <td width="139"><div align="right"><img src="image/separator.gif" width="2" height="400"></div></td>
  </tr>
  <tr>
    <td colspan="6"><img src="image/top2.gif" width="800" height="58">
<%}
if (web==0)
{
%>
 
 </table>
     <table width="800" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td height="599">
    <table width="800"  border="0"align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="6"><img src="image/top2.gif" width="800" height="58"></td>
  </tr>
  <tr>
    <td width="165" height="22"><img src="image/nav1.gif" width="165" height="22"></td>
    <td colspan="5" bgcolor="#CCCCCC"><img src="image/top2.gif" width="635" height="22"></td>
  </tr>
  <tr>
    <td colspan="6"><img src="image/spl_1.gif" width="76" height="72"><img src="image/top2.gif" width="724" height="72"></td>
  </tr>
  <tr>
    <td height="26">
     
   </td>
    <td colspan="4"><p align="center"><font size="+3" color="#0033FF" >欢迎光临普通用户界面</font></p></td>
    <td width="139"> </td>
  </tr>
  <tr>
    <td height="360"><img src="image/separator.gif" width="2" height="360"></td>
    <td width="165"><a href="yuangong/rest.jsp"><img src="image/qj.jpg" width="150" height="55" border="0"></a></td>
    <td width="117"></td>
    <td width="156"><a href="yuangong/restuser.jsp"><img src="image/qjcx.jpg" width="150" height="55" border="0"></a></td>
    <td width="76"> </td>
    <td width="139"><div align="right"><img src="image/separator.gif" width="2" height="360"></div></td>
  </tr>
  <tr>
    <td height="61" colspan="6"><img src="image/top2.gif" width="800" height="58"><%     }}
   else 
  {
     rs.close();
response.sendRedirect("error.jsp?msg=您好的输入有错误!");
     
     }
     
     %></td>
    </tr>
 
  </table>
  
    </td>
  </tr>
</table>
     
     
</body>
</html>
以下是error.jsp的内容
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>公司内部系统---</title>
<style type="text/css">
<!--
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    background-image: url(image/bj.gif);
}
.style1 {
    font-size: 16px;
    font-weight: bold;
}
.style2 {
    color: #0066FF;
    font-weight: bold;
    font-size: 18px;
}
-->
</style></head>
    <SCRIPT LANGUAGE="JavaScript">
function setf()
{
    document.for1.user.focus();
}
function cancle()
{    document.for1.user.value="";
    document.for1.pass.value="";
    return false;
}
function selec(txt)
{
    txt.focus();
    txt.select();
}
function chkUser(txt)
{  var user = document.for1.user;
    if (user.value=="")
    {
        alert ("please input username");
        selec(txt);
        return false;
    }else{
    return true;}
}
function chkPw(txt)
{  var pw = document.for1.pass;
    if (pw.value=="")
    {
        alert ("please input password");
        selec(txt);
        return false;
    }else{
    return true;}
}
function chkUserPw()
{var user = document.for1.user;
 var pw = document.for1.pass;
    if(chkUser(user))
    {
        if(chkPw(pw))
        {
            return true;
        }
        return false;
    }
    return false;
}
</SCRIPT>
<body>
<table width="800"  border="0"align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="6"><img src="image/top2.gif" width="800" height="58"></td>
  </tr>
  <tr>
    <td width="165" height="22"><img src="image/nav1.gif" width="165" height="22"></td>
    <td colspan="5" bgcolor="#CCCCCC"><img src="image/top2.gif" width="635" height="22"></td>
  </tr>
  <tr>
    <td colspan="6"><img src="image/spl_1.gif" width="76" height="72"><img src="image/top2.gif" width="724" height="72"></td>
  </tr>
  <tr>
    <td> </td>
    <td width="55"> </td>
    <td width="301"><div align="center" class="style2">公司内部管理系统</div></td>
    <td width="54"> </td>
    <td width="89"> </td>
    <td width="136"> </td>
  </tr>
  <tr>
    <td height="300"><img src="image/separator.gif" width="2" height="400"></td>
    <td> </td>
    <td><form action="logo.jsp" name="for1" method="post" onSubmit="return chkUserPw()"><table width="100%" border="0" >
      <tr>
        <td width="29%"> </td>
        <td width="31%"><span class="style1">username</span></td>
        <td width="29%"> </td>
        <td width="11%"> </td>
      </tr>
      <tr>
        <td> </td>
        <td><input type="text" name="user" size="12"> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td><span class="style1">password</span></td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td> </td>
        <td><input type="password" name="pass" size="16"> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td align="center"><input type="image" border="0" name="imageField" src="image/login.gif" width="60" height="25"></td>
        <td> </td>
        <td><input type="image" border="0" name="imagereset" src="image/reset.gif" width="60" height="25" onClick="return cancle();"></td>
        <td> </td>
      </tr>
      <tr>
        <td colspan="3">
        <%
        request.setCharacterEncoding("gb2312");
        String msg=new String(request.getParameter("msg").getBytes("ISO8859_1"),"GBK");
        if(msg!=null)
           out.print("<br>"+msg);
        %>
        </td>
        <td> </td>
      </tr>
    </table>
    </form></td>
    <td> </td>
    <td> </td>
    <td><img src="image/separator.gif" width="2" height="400" align="right"></td>
  </tr>
  <tr>
    <td colspan="6"><img src="image/top1.gif" width="800" height="58"></td>
  </tr>
</table>
</body>
</html>
红色部分为所述代码!

	    2007-02-06 17:55
  我在String msg=new String(request.getParameter("msg").getBytes("ISO8859_1"),"GBK");之前有加这句呀,request.setCharaterEncoding("GB2312");

	    2007-02-07 10:55
  
	    2007-02-07 15:32
  也试了,产生错误信息
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 170 in the jsp file: /www/logo.jsp
Generated servlet error:
    [javac] Compiling 1 source file
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\www\logo_jsp.java:299: unclosed string literal
    response.sendRedirect("error.jsp?msg=<%=URLEncoder.encode('?ㄥソ????ユ????!')
                              ^
An error occurred at line: 173 in the jsp file: /www/logo.jsp
Generated servlet error:
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\www\logo_jsp.java:300: ')' expected
      out.write("\");\r\n\t }\r\n\t \r\n\t %>");
                                               ^
An error occurred at line: -1 in the jsp file: null
Generated servlet error:
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\www\logo_jsp.java:309: 'catch' without 'try'
    } catch (Throwable t) {
      ^
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\www\logo_jsp.java:31: 'try' without 'catch' or 'finally'
    try {
    ^
D:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\www\logo_jsp.java:319: '}' expected
^
5 errors
我是直接搬上去的.

	    2007-02-07 16:02