资源简介
实现用户在线投票,IP限制。管理员后台管理,主题的添加与修改。
代码片段和文件信息
package votebean;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author xiaoq
*
*/
public class AddVoteServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public AddVoteServlet() {
super();
}
/**
* Destruction of the servlet.
*/
public void destroy() {
super.destroy(); // Just puts “destroy“ string in log
// Put your code here
}
/**
* The doPost method of the servlet.
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
response.setContentType(“text/html;charset=GBK“);
PrintWriter out = response.getWriter();
out.println(““);
out.println(“ tle>add vote tle>“);
out.println(“ “);
String title=request.getParameter(“title“);
String stile=request.getParameter(“stile“);
String startTime=request.getParameter(“startyear“)+“-“+request.getParameter(“startmonth“)+“-“+
request.getParameter(“startday“);
String endTime=request.getParameter(“endyear“)+“-“+request.getParameter(“endmonth“)+“-“+
request.getParameter(“endday“);
String active=request.getParameter(“active“);
int newActive=Integer.parseInt(active);
/**test
out.println(title+““+stile+““+endTime+““+startTime+““+newActive+““);
*/
Questions question=new Questions();
question.settitle(title);
question.setstyle(stile);
question.setStrStartime(startTime);
question.setStrEndtime(endTime);
question.setActive(newActive);
int n=Integer.parseInt(request.getParameter(“n“));
Collection items=new ArrayList();
Item item=null;
for(int i=1;i<=n;i++){
item=new Item();
item.setOptions(request.getParameter(“option“+i));
items.add(item);
item=null;
}
VoteMgr mgr=new VoteMgr();
question.setItem(items);
int i=mgr.addVote(question);
if(i==1){
out.print(“add successed“);
}else{
out.print(“add failedplease add again“);
}
out.println(“继续添加|“);
out.println(“浏览投票项目“);
out.println(“ “);
out.println(““);
out.flush();
out.close();
}
/**
* Initialization of the servlet.
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 580 2014-12-10 12:26 vote\.classpath
文件 285 2014-12-10 12:26 vote\.myme
文件 1747 2014-12-10 12:26 vote\.project
文件 500 2014-12-10 12:26 vote\.settings\.jsdtscope
文件 103 2014-12-13 23:25 vote\.settings\org.eclipse.core.resources.prefs
文件 334 2014-12-10 12:26 vote\.settings\org.eclipse.jdt.core.prefs
文件 450 2014-12-10 12:26 vote\.settings\org.eclipse.wst.common.component
文件 252 2014-12-10 12:26 vote\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2014-12-10 12:26 vote\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2014-12-10 12:26 vote\.settings\org.eclipse.wst.jsdt.ui.superType.name
....... 2945 2008-12-17 02:47 vote\src\votebean\AddVoteServlet.java
文件 2163 2014-12-13 23:43 vote\src\votebean\BrowseVoteServlet.java
....... 1425 2008-12-17 22:43 vote\src\votebean\DeleteVoteServlet.java
....... 2573 2008-12-17 22:40 vote\src\votebean\EditVoteServlet.java
....... 596 2008-12-10 21:26 vote\src\votebean\Item.java
文件 738 2014-12-10 13:38 vote\src\votebean\MysqlDAO.java
文件 2684 2014-12-14 02:19 vote\src\votebean\MysqlTest.java
....... 2062 2008-12-16 19:08 vote\src\votebean\Questions.java
文件 2804 2014-12-12 01:24 vote\src\votebean\ServletLogin.java
....... 1999 2008-12-18 13:39 vote\src\votebean\ShowVoteServlet.java
文件 2460 2014-12-14 02:59 vote\src\votebean\UpdateVoteServlet.java
文件 10257 2014-12-13 23:39 vote\src\votebean\VoteMgr.java
文件 3136 2014-12-14 00:36 vote\src\voteuser\ShowServlet.java
文件 1223 2014-12-14 02:33 vote\src\voteuser\VoteMeoryDao.java
文件 379 2014-12-13 23:56 vote\src\voteuser\VoterMemory.java
文件 4457 2014-12-11 00:55 vote\WebRoot\admin\addvote.jsp
文件 4454 2014-12-12 01:31 vote\WebRoot\admin\browse.jsp
文件 5582 2014-12-11 00:56 vote\WebRoot\admin\editVote.jsp
文件 1463 2014-12-12 01:18 vote\WebRoot\admin\error.jsp
文件 859 2014-12-14 00:39 vote\WebRoot\admin\index.jsp
............此处省略44个文件信息
- 上一篇:用java语言编写的递归下降语法分析器
- 下一篇:javacc实现cmm语法分析
评论
共有 条评论