导航:首页 > 编程语言 > jsp在线投票系统源码

jsp在线投票系统源码

发布时间:2023-07-29 03:48:30

『壹』 网站投票系统代码(java web)

http://www.onegreen.net/code/HTML/10633.html 你看看这个行不行 如果行的话 请采纳

『贰』 jsp 投票系统怎么实现投的票计数啊投得票数的多少放入数据库中吗

恩,要用到数据库的。给你写个页面的代码,不过读取数据库和更新数据库的代码就要你自己写了。这儿只是这个jsp中变化的,页面关了数值都会重置。所以要用到数据库,传值和调用并显示就看你写了,
<html>
<head>

<title>My JSP 'main.jsp' starting page</title>

<script type="text/javascript">
var i=0;
var j=0;
function addi(){
++i;
document.getElementById("_good").value=i+" 满意";
}
function addj(){
++j;
document.getElementById("_bad").value=j+" 不满意";
}
</script>

</head>

<body>
<center>
<table>
<tr><td><input type="button" id="_good" onmouseup="addi()" value="0 满意"/></td>
<td><input type="button" id="_bad" onmouseup="addj()" value="0 不满意"/></td></tr>
</table>

</center>
</body>
</html>

//要全部代码可以说下

『叁』 基于JSP技术的网上在线招投标系统的设计与实现

建立一套适用于招投标企业和交易中心之间及时进行招投标业务数据交流内、具有良好数据通讯容交换能力、管理流程规范、管理模型统一、并具有分析项目数据和大数据量处理能力的综合性招投标管理信息系统,通过系统的建设和实施,提高建设工程招投标的工作效率和管理水平,并且为上下级招投标业务主管部门之间一个提供数据报送和管理平台。提高建设工程招投标政府主管部门的信息化管理水平和政务的公开透明程度,提高招投标活动的执行效率和管理水平,推出建设工程招投标管理信息系统解决方案。
主要应用对象:各省、市、地区招标办;

『肆』 用jsp做网上投票系统 代码

我之前做过类似的投票小项目,在这里把源码发给你。你自己好好的参考一下。--------------------------package com.tv.bean;public class TVBean {
private String tvName;
private int tvCount;

public String getTvName() {
return tvName;
}
public void setTvName(String tvName) {
this.tvName = tvName;
}
public int getTvCount() {
return tvCount;
}
public void setTvCount(int tvCount) {
this.tvCount = tvCount;
}
}------------------------------package com.tv.;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;import com.tv.bean.TVBean;
public class DBUtil {
private Connection con;
private PreparedStatement ps = null;
private ResultSet rs;
public void getCon(){
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=TV","sa","");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
}

public void closeCon(){
try {
if(rs !=null) rs.close();
if(ps != null) ps.close();
if(con != null) con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}

public ArrayList getAll(){
ArrayList al = new ArrayList();
this.getCon();
String sql = "select * from TVInfo order by tvCount desc";
try {
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
while(rs.next()){
TVBean tb = new TVBean();
tb.setTvName(rs.getString(1));
tb.setTvCount(rs.getInt(2));
al.add(tb);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
this.closeCon();
}
return al;
}

public boolean updateByName(String name){
this.getCon();
String sql = "update TVInfo set tvCount=tvCount+1 where tvName='"+name+"'";
try {
ps = con.prepareStatement(sql);
int i = ps.executeUpdate();
if(i > 0) return true;
else return false;
} catch (SQLException e) {
e.printStackTrace();
return false;
} finally {
this.closeCon();
}
}
}
---------------------------------------package com.tv.servlet;import java.io.IOException;
import java.util.ArrayList;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;import com.tv..DBUtil;public class VoteServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
DBUtil = new DBUtil();
String [] name = request.getParameterValues("tvs");
int num = name.length;
for(int i =0; i < num; i++){
if(.updateByName(name[i])){
request.setAttribute("to", "投票成功!");
ArrayList al = .getAll();
HttpSession session = request.getSession();
session.setAttribute("al", al);
request.getRequestDispatcher("success.jsp").forward(request, response);
}else{
request.setAttribute("to", "投票失败!请重新再试!");
}
}

} public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
}
}
-----------------------------------<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri=" http://java.sun.com/jsp/jstl/core"%><html>
<head>
<title>电视投票</title>
</head> <body>
<center>
<form action="vote" method="post">
<table border="1" align="center">
<tr align="center">
<td>
<h2>
选择您最喜欢的电视剧并投上一票
</h2>
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="tvs" value="咏春" />
咏春
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="tvs" value="金婚" />
金婚
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="tvs" value="士兵突击" />
士兵突击
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="tvs" value="少年张三丰" />
少年张三丰
</td>
</tr>
<tr>
<td align="center">
<input type="submit" value=" 提交 " />

<input type="reset" value=" 重置 " />
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
-------------------------------------第一段代码为JavaBean;第二段代码为数据库连接类;第三段代码为Servlet控制类;第四段代码为JSP显示页面。希望能够解决你的问题!

『伍』 网上下载的JSP网上选课系统(源代码)怎么在自己的电脑运行

下载tomcat并打开tomcat/bin/starup.bat 把代码放进tomcat/webapps。 用浏览器输入 这样的地址 http://127.0.0.1:8080/book/teacher.jsp 我的代码在 tomcat/webapps/book/teacher.jsp,可专以在webapps 里面建属文件夹。

『陆』 HTML5代码里能怎么才能写jsp代码

HTML5代码可以和jsp混合在一起。
JSP实质上只是为HTML页面封装了对HTTP协议的Request对象和Rsponse对象而已。
就比如说,获取敬宽上一个页面的数据、操作Session等。
这也就是,为什么会说“JSP是在HTML里面写Java代码,弯稿扒而Servlet是在JAVA里面写HTML代码”
其实不过是封装了HTTP协议的埋昌请求响应而已。
而HTML5,只是HTML语言的新一代标准。

『柒』 jsp投票系统求源代码!可以连数据库的!

<p style=line-height: 150%><SPAN style="FONT-SIZE: 12px"><STRONG>这是用文本文件作为存储载体的投票系统:</STRONG></SPAN>
<p style=line-height: 150%><SPAN style="FONT-SIZE: 12px"><STRONG>vote.java:</STRONG></SPAN>
<SPAN style="FONT-SIZE: 12px"><STRONG></STRONG> <p style=line-height: 150%>
// Java Document
package vote;
import java.io.*;
import java.util.*;
public class vote extends Object
{
public String filePath="";
public int n;
private File voteFile;
private BufferedReader fileRead;
private PrintWriter fileWrite;
public String systemMessage="";
private String voteStr[]=new String[10];
public int voteNum[]=new int[10];
public void createFile()
throws FileNotFoundException
{
voteFile=new File(filePath);
if(!voteFile.exists())
{
fileWrite=new PrintWriter(new FileOutputStream(filePath));
for(int i=0;i<n;i++) fileWrite.println("0");
fileWrite.close();
}
}
public void writeFile()
throws FileNotFoundException
{
fileWrite=new PrintWriter(new FileOutputStream(filePath));
for(int i=0;i<n;i++)
{
fileWrite.println(voteNum[i]);
}
fileWrite.close();
}
public void readFile()
throws FileNotFoundException
{
fileRead=new BufferedReader(new FileReader(filePath));
for(int i=0;i<n;i++)
{
try
{voteStr[i]=fileRead.readLine();
}
catch(IOException f)
{
voteStr[i]="0";}
voteNum[i]=Integer.parseInt(voteStr[i]);
}
try
{
fileRead.close();
}
catch(IOException d)
{
systemMessage=d.toString();
}
}
}
<p style=line-height: 150%><SPAN style="LINE-HEIGHT: 15pt"><SPAN style="FONT-SIZE: 12px"><STRONG>vote.jsp:</STRONG>

<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<%@ page import="java.util.*"%>
<%@ page import="java.lang.*"%>
<%@ page import="java.io.*"%>
<jsp:useBean id="vote" scope="request" class="vote.vote"/>
<%
String vote1=request.getParameter("lang");
vote.n=4;
vote.filePath="vote.txt";
vote.createFile();
vote.readFile();
if(vote1.compareTo("0")==0)
vote.voteNum[0]++;
if(vote1.compareTo("1")==0)
vote.voteNum[1]++;
if(vote1.compareTo("2")==0)
vote.voteNum[2]++;
if(vote1.compareTo("3")==0)
vote.voteNum[3]++;
vote.writeFile();
%>
<script language="javascript">
alert("感谢你投了宝贵的一票");
self.location="index.jsp";
</script></SPAN></SPAN>
<p style=line-height: 150%><STRONG> </STRONG><SPAN style="LINE-HEIGHT: 15pt"><SPAN style="FONT-SIZE: 12px"><STRONG>see.jsp:</STRONG>

<%@ page contentType="text/html; charset=gb2312" language="java" errorPage="" %>
<%@ page import="java.util.*"%>
<%@ page import="java.lang.*"%>
<%@ page import="java.io.*"%>
<jsp:useBean id="vote" scope="request" class="vote.vote"/>
<%
String vote1=request.getParameter("lang");
vote.n=4;
vote.filePath="vote.txt";
vote.createFile();
vote.readFile();
int total=0;
float voteFlo[]=new float[5];
for(int i=0;i<4;i++) total+=vote.voteNum[i];
for(int i=0;i<4;i++) voteFlo[i]=150*((float)vote.voteNum[i]/(float)total);
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>查看调查</title>
<link href="t1.css" rel="stylesheet" type="text/css">
</head>
<body>

<table width="30%" border="0" class="t1">
<tr>
<td colspan="2"><div align="center">调查结果</div></td>
</tr>
<tr>
<td width="18%">JSP</td>
<td width="82%"><img src="bar.gif" width=<%=voteFlo[0]%> height=8> <%=vote.voteNum[0]%></td>
</tr>
<tr>
<td>ASP</td>
<td><img src="bar.gif" width=<%=voteFlo[1]%> height=8> <%=vote.voteNum[1]%></td>
</tr>
<tr>
<td>PHP</td>
<td><img src="bar.gif" width=<%=voteFlo[2]%> height=8> <%=vote.voteNum[2]%></td>
</tr>
<tr>
<td>其他</td>
<td><img src="bar.gif" width=<%=voteFlo[3]%> height=8> <%=vote.voteNum[3]%></td>
</tr>
<tr>
<td colspan="2"><div align="center"><a href="javascript:window.close();">关闭窗口</a></div></td>
</tr>
</table>
</body>
</html>
</SPAN></SPAN>
<p style=line-height: 150%><SPAN style="LINE-HEIGHT: 15pt"><SPAN style="FONT-SIZE: 12px"><SPAN style="LINE-HEIGHT: 15pt"><SPAN style="FONT-SIZE: 12px"><STRONG>index.jsp:</STRONG>
</SPAN></SPAN>
</SPAN></SPAN> <p style=line-height: 150%><SPAN style="LINE-HEIGHT: 15pt"><SPAN style="FONT-SIZE: 12px"><%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>投票</title>
<link href="t1.css" rel="stylesheet" type="text/css">
</head>
<script language="javascript">
function cw()
{window.open("see.jsp","mywindow","toolbar=no,left=150,top=200,width=270,height=350,menubar=no,systemMenu=no");
}
</script>
<body>
<table width="15%" height="250" align="left">
<tr>
<td><form name="form1" method="post" action="vote.jsp">
<table width="100%" height="250" border="1" align="center" bordercolor="#9966CC" class="t1">
<tr>
<td><div align="left">你所使用的开发语言</div></td>
</tr>
<tr>
<td><input type="radio" name="lang" value="0">
JSP</td>
</tr>
<tr>
<td><input type="radio" name="lang" value="1">
ASP</td>
</tr>
<tr>
<td><input type="radio" name="lang" value="2">
PHP</td>
</tr>
<tr>
<td><input type="radio" name="lang" value="3">
其他 </td>
</tr>
<tr>
<td><div align="center">
<input name="vote" type="image" src="poll.gif" width="40" height="20" border="0">
<a href="javascript:cw()"><img src="see.gif" width="40" height="20" border="0"></a></div></td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
</html>
</SPAN></SPAN></SPAN>

『捌』 jsp中网站的首页源代码

这是最简单的一个例子,数据库要你自己建,用的是ACCESS

<%@pagecontentType="text/html;charset=gb2312"language="java"import="java.sql.*"errorPage=""%>

<html>

<head>

<metancon=DriverManager.getConnection("jdbc:odbc:jspdata");//建立数据库链陆告早接,jspdata为ODBC数据源名称

//建立Statement对象

Statementstmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

ResultSet.CONCUR_READ_ONLY);

ResultSetrs=stmt.executeQuery("select*fromlyb");//建立ResultSet(结果集)对象,并执行SQL语句

%>

</p>

<palign="center">NUMB1数据表中记录如友悉下</p>

<tablewidth="640"border="1"align="center"bordercolor="7188e0">

<trbgcolor="d1d1ff">

<thwidth="49">编号</th>

<thwidth="90">姓名</th>

<thwidth="126">E-mail</th>

<早雀thwidth="221">网站</th>

<thwidth="80">QQ</th>

</tr>

<%

while(rs.next())

{

%>

<trbgcolor="f8f8f8">

<th><%=rs.getString(1)%></th>

<th><%=rs.getString(2)%></th>

<th><%=rs.getString(3)%></th>

<thbgcolor="f6f6f8"><%=rs.getString(4)%></th>

<th><%=rs.getString(5)%></th>

</tr>

<%

}

rs.close();

stmt.close();

con.close();

%>

</table>

<palign="center"><br>

如果您能看到表格中的数据,说明连接数据库成功!</p>

</body>

</html>

『玖』 jsp 中网站的首页源代码

这是最简单的一个例子,数据库要你自己建,用的是ACCESS

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JSP连接Access数据库</title>
<style type="text/css">
<!--
.style1 {
font-size: 20px;
font-weight: bold;
}
-->
</style>
</head><body>
<div align="center" class="style1">JSP连接Access数据库</div>
<br>
<hr>
<p><%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //载入驱动程序类别
Connection con = DriverManager.getConnection("jdbc:odbc:jspdata"); //建立数据库链接,jspdata为ODBC数据源名称
//建立Statement对象
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet rs = stmt.executeQuery("select * from lyb"); //建立ResultSet(结果集)对象,并执行SQL语句
%>
</p>
<p align="center">NUMB1数据表中记录如下</p>
<table width="640" border="1" align="center" bordercolor="#7188e0">
<tr bgcolor="d1d1ff">
<th width="49">编号</th>
<th width="90">姓名</th>
<th width="126">E-mail</th>
<th width="221">网站</th>
<th width="80">QQ</th>
</tr>
<%
while(rs.next())
{
%>
<tr bgcolor="#f8f8f8">
<th><%= rs.getString(1) %></th>
<th><%= rs.getString(2) %></th>
<th><%= rs.getString(3) %></th>
<th bgcolor="#f6f6f8"><%= rs.getString(4) %></th>
<th><%= rs.getString(5) %></th>
</tr>
<%
}
rs.close();
stmt.close();
con.close();
%>
</table>
<p align="center"><br>
如果您能看到表格中的数据,说明连接数据库成功!</p>
</body>
</html>

阅读全文

与jsp在线投票系统源码相关的资料

热点内容
macbookpro如何修改文件内容 浏览:965
java稳定排序 浏览:53
oppo文件管理的图片 浏览:335
plc编程步数怎么计算 浏览:142
ipad看电脑文件 浏览:935
成都制作pdf文件 浏览:735
怎么样点开电脑里面的网络连接 浏览:755
微信怎么退出账号 浏览:32
w微信开发者工具 浏览:325
数据库还原附加 浏览:713
打包成exe执行文件 浏览:652
信丰营销app有哪些 浏览:463
苹果文件下载项如何下载 浏览:179
ps抠婚纱教程 浏览:203
如何在移动硬盘上隐藏文件夹 浏览:451
瑞虎8老车机怎么刷app 浏览:992
学ui设计要学java吗 浏览:275
淘宝票房数据源怎么调整 浏览:470
iphone5s升级ios卡黑屏 浏览:622
u盘没用的文件删不了怎么办 浏览:561

友情链接