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>