用JSP+Javabean+Servlet实现一个投票系统

//index   用于登陆等功能的实现

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>欢迎</title>
<link rel="stylesheet" href="3col_leftNav.css" type="text/css" />
<style type="text/css">
<!--
.STYLE1 {font-size: 18%}
.STYLE3 {
 font-size: large;
 font-weight: bold;
 color: #996600;
}
.STYLE4 {
 font-size: medium;
 font-weight: bold;
}
.STYLE5 {color: #00CC66}
-->
</style>
</head>
<body>
<form name="form1" method="post" action="login.jsp">
<hr>
 
  <div id="globalNav"> <a href="index.jsp">首页</a> |  | <a href="registration.jsp">注册</a> | |<a href="./http://www.jmu.edu.cn"> 集美大学</a> ||</div>
  <h2 id="pageName">集美大学</h2>

  <div class="STYLE1" id="breadCrumb" >
    <p>欢迎登陆到集美大学投票系统进行新校名的投票!新用户请注册再登陆,谢谢!</p>
    <hr>
  </div>
<div id="navBar">
  <div id="search">
   
      <label>用户名</label>
    <input name="userId" type="text" size="20" />
   
 
  </div>
  <div class="relatedLinks">
    <h3>密码 <br />
 <input name="password" type="password" size="20"/ >
 <input name="submit" type="submit" value="go" size="50" />
    </h3>
  </div>
 
  <div class="relatedLinks">
  
    <p>&nbsp;</p>
    <p class="STYLE4"><a href="registration.jsp" class="STYLE5">如果你是新用户请点击这里注册!</a></p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
  </div>
 
</div>
<!--end navBar div -->
<div id="headlines">
  <h3><%@ include file="CounterApp.jsp"%></h3>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p><a href="#">.</a> </p>
  <p>&nbsp;</p>
  <div id="advert"></div>
</div>
<!--end headlines -->
<div id="content">
  <div class="feature"> <img src="04.jpg" alt="" width="225" height="228" />
    <h3 class="STYLE4">集美大学简介</h3>
    <p>Jimei University, approved by the Ministry of Education, is a key   provincial multi-disciplined university which was combined into one from five   individual institutes and colleges in Jimei Schools Village, namely, Jimei   Navigation Institute, Xiamen Fisheries College, Fujian Physical Education   College, Jimei Finance and Economics Institute, and Jimei Teachers College in   October 1994. Secretary of CPC of JMU: Prof. Xiangzhong Zhang<br />
      President of JMU: Prof.   Jiande Gu<br />
      Add: Jimei Schools Village, Xiamen, 361021, Fujian Province, P. R.   China<br />
      Tel: 0086-592-6181097 Fax: 0086-592-6180120<br />
      
  </div>
  <div class="story">
    <h3>
      <!--end content -->
</h3>
  </div>
</div>
<div id="siteInfo"> <img src="20055291316679.jpg" width="65" height="21" /><span class="STYLE3">welcome</span> <span class="STYLE3">welcome</span> <span class="STYLE3">welcome</span> <span class="STYLE3">welcome</span> <span class="STYLE3">welcome</span> <span class="STYLE3">welcome</span> <span class="STYLE3">welcome</span> <span class="STYLE3">welcome</span> <span class="STYLE3">welcome</span></div>
<br />
</form>
</body>
</html>

//验证登陆界面

<%@ include file="include.inc"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<%
//获得请求的参数。
String id=request.getParameter("userId");
String psw=request.getParameter("password");
//连接数据库
Class.forName(CLASSFORNAME);
Connection con = DriverManager.getConnection(SERVANDDB,USER,PWD);
Statement statement=con.createStatement();
String isCorrect="select * from user_info where userId='" + id + "' and password='" + psw + "'";
ResultSet result=statement.executeQuery(isCorrect);
 session.setAttribute("isLog",new String("0"));

if(!result.next())
{
 
response.sendRedirect("index.jsp");//账号或密码错误,转入错误页面
result.close();
statement.close();
con.close();
}
 //如果查询后有记录,说明登录验证成功。
else
{
      //保存登录信息到session对象中。
   session.setAttr

  • 2
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值