资源简介
jsp界面弄的一个很简单的抽奖项目,可供大家参考参考

代码片段和文件信息
package servlet;
import java.io.IOException;
import java.util.Random;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ResultServlet extends HttpServlet {
/**
* Constructor of the object.
*/
public ResultServlet() {
super();
}
/**
* Destruction of the servlet.
*/
public void destroy() {
super.destroy(); // Just puts “destroy“ string in log
// Put your code here
}
/**
* The doGet method of the servlet.
*
* This method is called when a form has its tag value method equals to get.
*
* @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 doGet(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
doPost(requestresponse);
}
/**
* 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 {
request.setCharacterEncoding(“utf-8“);
String path = “/result.jsp“;// 转发到的页面
RequestDispatcher rd = request.getRequestDispatcher(path);// 实现转发功能
String[] a={“没有中奖,谢谢光顾!““没有中奖,谢谢光顾!““没有中奖,谢谢光顾!““恭喜你中奖了,详情请登录***网站了解““没有中奖,谢谢光顾!““恭喜你中了特等奖了,详情请登录***网站了解““恭喜你中了大奖了,详情请登录***网站了解““谢谢光顾““没有中奖,谢谢光顾!““没有中奖,谢谢光顾!“};
String aa=getRandomString(a);
request.setAttribute(“result“ aa);
//request.setAttribute(“result“ “success“);// 调用request的属性函数
//request.setAttribute(“reson“ “注册成功!“);// 调用request的属性函数
rd.forward(request response);
return;
//System.out.println (getRandomString(a));
}
public static String getRandomString(String[] str){
Random rand=new Random(System.currentTimeMillis());
return str[rand.nextInt(10)];
}
/**
* Initialization of the servlet.
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1223 2010-03-08 16:27 Tests\.project
文件 2755 2010-03-08 19:38 Tests\src\servlet\ResultServlet.java
文件 2212 2010-03-08 19:38 Tests\WebRoot\WEB-INF\classes\servlet\ResultServlet.class
文件 662 2010-03-08 16:48 Tests\WebRoot\WEB-INF\web.xm
文件 39 2010-03-08 14:45 Tests\WebRoot\me
文件 1730 2010-03-08 17:12 Tests\WebRoot\index.jsp
文件 22856 2010-03-08 15:19 Tests\WebRoot\image\1.jpg
文件 14949 2010-03-08 15:18 Tests\WebRoot\image\3.jpg
文件 17200 2010-03-08 17:23 Tests\WebRoot\image\4.jpg
文件 1353 2010-03-08 18:06 Tests\WebRoot\result.jsp
文件 288 2010-03-08 14:45 Tests\.myme
文件 362 2010-03-08 15:18 Tests\.classpath
目录 0 2010-03-08 19:34 Tests\WebRoot\WEB-INF\classes\servlet
目录 0 2010-03-08 14:45 Tests\WebRoot\WEB-INF\lib
目录 0 2010-03-08 14:45 Tests\WebRoot\WEB-INF\classes
目录 0 2010-03-08 16:48 Tests\src\servlet
目录 0 2010-03-08 14:45 Tests\WebRoot\WEB-INF
目录 0 2010-03-08 14:45 Tests\WebRoot\me
目录 0 2010-03-08 15:18 Tests\WebRoot\image
目录 0 2010-03-08 14:45 Tests\src
目录 0 2010-03-08 14:45 Tests\WebRoot
目录 0 2010-03-08 14:45 Tests\.myeclipse
目录 0 2010-03-08 14:45 Tests
----------- --------- ---------- ----- ----
65629 23
- 上一篇:android wifi 热点模式使用
- 下一篇:java 网上在线报名系统
相关资源
- 微博系统(Java源码,servlet+jsp),适
- JSP企业人事管理系统设计(源代码+论
- 实现一个图书管理系统
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- JSP,SQL,MVC的选课系统
- 基于JSP的学生宿舍管理系统(源码 数
- JSP选课管理系统
- mysql jsp网站源码下载
- JSP做的化妆品商城
- Jsp购物车实例
- 基于JSP的校友信息管理系统(添加数
- 基于jsp的bbs论坛 非常详细
- jsp oracle通讯录
- JSP学生信息管理系统 Mysql数据库
- 使用jsp servlet做的投票系统
- JSP登陆验证 实现JSP用户名 密码 验
- jsp基于servlet 图书馆管理系统
- jsp学生成绩管理系统.rar
- 在线考试系统源代码(jsp)
- 超级好的纯jsp写的聊天室
- JSP 网上购物网页项目
- JSP+mysql新闻发布系统.rar
- jsp 学生信息管理系统设计与实现
- jsp与SQL Server数据库实现的客户注册登
- 简易教学管理系统(jsp spring struts h
- 学生信息管理系统 JSP MySQL
- jsp ajax 三级联动菜单
- jsp新闻公告与最新消息系统(具备添
- JSP课程设计-留言本 jsp mysql tomcat实现
评论
共有 条评论