您好,欢迎光临本网站![请登录][注册会员]  
文件名称: Servelt技术做的E家园
  所属分类: Java
  开发工具:
  文件大小: 5kb
  下载次数: 0
  上传时间: 2009-10-25
  提 供 者: cza***
 详细说明: package AiSoft.OwnHome.Servlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import AiSoft.OwnHome.Bean.Article; import AiSoft.OwnHome.Common.VString; import AiSoft.OwnHome.Opreation.ArticleDao; public class DetailServlet extends HttpServlet { /** * Constructor of the object. */ public DetailServlet() { 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 { this.doPost(request, response); } /** * 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=gb2312"); response.setCharacterEncoding("gb2312"); PrintWriter out = response.getWriter(); // 从客户端获得articlId String temp = VString.ValidateString(request.getParameter("articleId")); // 文章ID int articleId = 0; // 如果文章ID不为空 if (temp != null || (!"".equals(temp))) { articleId = Integer.parseInt(temp); // 强制转换 } // 获得ArticleDao类 ArticleDao articleDao = new ArticleDao(); // 获得文章对象 Article article = articleDao.GetArticleById(articleId); //获取文章存在时就保存在request对象里 if (article != null) { // 把文章存放在request对象 request.setAttribute("currentArticle", article); // 请求重转发 request.getRequestDispatcher("detailArticle.jsp").forward(request, response); } //否则就提示用户不存在其文章 else{ out.println(""); } } /** * Initialization of the servlet.
* * @throws ServletException * if an error occure */ public void init() throws ServletException { // Put your code here } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: Servlet+JavaBean
 输入关键字,在本站1000多万海量源码库中尽情搜索: