这个是登陆页面 用户名跟密码是固定的 允许有权限的用户添加或删除新闻<jsp:include page="temp.jsp"/>
<html>
 <head>
  <title>登陆系统</title>
  <meta http-equiv="Content-Type" content="text/html;charset=gb2312">
 </head>
<%@ page contentType="text/html;charset=gb2312"%>
<body bgcolor="#FFFFFF text="#000000">
 <div align="center">
 <form name="form1" method="post" action="adjust.jsp">
 <h2>登陆武汉新闻管理系统</h2>
 <p>用户名;
 <input type="text" name="un" size="8">
 <br>
 密 &nbsp;码:
 <input type="password" name="ps" size="8">
 <br>
 <input type="submit" name="Submit" value="进入">
 <br>
 <br>
 </p>
 </form>
 <p>&nbsp;</p>
 </div>
</body>
</html>

解决方案 »

  1.   

    这个是判断登陆页面  <html>
     <head>
      <title>Untitled Document</title>
      <meta http-equiv="Content-Type" content="text/html;charset=gb2312">
     </head>
     <%!
      public String change(String a)
      {
       try
       {
        String temp=a;
        byte[] temp2=temp.getBytes("ISO8895-1");
        String temp3=new String(temp2);
        return temp3;
       }
       catch(Exception e)
       {
       }
       return "null";
      }
     %>
     <%
       String username="admin";
       String password="admin";
     %>
     <body bgcolor="#FFFFFF" text="#000000">
     <%
       String tempname=request.getParameter("un");
       String temppass=request.getParameter("ps");
       tempname=change(tempname);
       temppass=change(temppass);
       if(tempname.equals("admin")&&temppass.equals("admin"))
       {
       session.putValue("un",tempname);
       response.sendRedirect("choose.jsp");
       }
       else
       {
        response.sendRedirect("relogin.jsp");
       }
      %>
      </body>
    </html>这个是relogin.jsp 登陆失败时出现的重新登陆
    <html>
     <head>
      <title>登陆系统</title>
      <meta http-equiv="Content-Type" content="text/html;charset=gb2312">
     </head>
     <%@ page contentType="text/html;charset=gb2312"%>
     <body bgcolor="#FFFFFF" text="#000000">
       <div align="center">
     <form name="form1" method="post" action="adjust.jsp">
     <h2>
       登陆武汉新闻管理系统
     </h2>
     <p>
      <font color="#FF0000">用户名或密码错误,请重新登陆<br>
      </font><br>
      </p>
      <p>
      用户名:
      <input type="text" name="un" size="8">
      <br>
      密 &nbsp;码:
      <input type="password" name="ps" size="8">
      <br>
      <input type="submit" name="Submit" value="进入">
      </p>
      </form>
      <p>&nbsp;</p>
      </div>
     </body>
    </html>
    这个是choose.jsp页面 登陆成功后 提供用户选择的页面(包括录入与删除)
    <%@ include file="temp.jsp"%>
    <html>
     <head>
      <title>Untitled Document</title>
      <meta http-equiv="Content-Type" content="text/html;charset=gb2312">
     </head>
     <%@ page contentType="text/html;charset=gb2312"%>
     <body bgcolor="#FFFFFF" text="#000000">
      <p>
      <a href="insert.jsp">录入</a></p>
      <p>
      <a href="delete.jsp">删除</a></p>
     </body>
    </html>
      

  2.   

    这个是insert.jsp  登陆成功后 新闻录入 <%@ include file="temp.jsp"%>
    <html>
     <head>
      <title>Untitled Document</title>
      <meta http-equiv="Content-Type" content="text/html;charset=gb2312">
     </head>
     <%@ page contentType="text/html;charset=gb2312"%>
     <body bgcolor="#FFFFFF" text="#000000">
      <div align="center">
      <form name="form1" method="post" action="save.jsp">
      <table width="760" border="0">
      <tr>
      <td height="441" valign="top">
      <div align="center">
      <h2>武汉新闻管理系统</h2>
      <b>.......新闻录入.......</b><br>
      <b><br>
      期号:</b>
      <input type="text" name="issue" size="40">
      <br>
      <b>标题:</b>
      <input type="text" name="topic" size="40">
      <br>
      <b>内容</b>:
      <textarea name="content" rows="20" cols="40"></textarea>
      <br>
      <input type="submit" name="Submit" value="保存">
      </div>
      </td>
      </tr>
      </table>
      </form>
      </div>
     </body>
    </html>
    这个是delete.jsp  新闻删除页面
    <%@ include file="temp.jsp"%>
    <html>
      <head>
      <title>
        删除
      </title>
      <meta http-equiv="Content-Type" content="text/html;charset=gb2312">
      </head>
    <%@ page contentType="text/html;charset=gb2312"%>
    <body bgcolor="#FFFFFF" text="#000000">
     <div align="center">
     <p><b>删除新闻</b><br>
     </p>
     <form name="form1" method="post" action="del,jsp">
     请输入ID
     <input type="text" name="delid">
     <br>
     <input type="submit" name="Submit" value="ok">
     <br>
     <br>
     </form>
     <p>&nbsp;</p>
     <p>&nbsp;</p>
     </div>
    </body>
    </html>