java+MySql制作B/S电子商务网站 第4页

java+MySql制作B/S电子商务网站 第4页

package com.aheadedu.zyy;

import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

import java.util.*;

import java.sql.*;

public class ggaddServlet extends HttpServlet {

    private static final String CONTENT_TYPE = "text/html; charset=GBK";

    Connection conn = null;

    //Initialize global variables

    public void init() throws ServletException {

        com.aheadedu.zyy.DbTool dbtool = new com.aheadedu.zyy.DbTool();

        conn = dbtool.getConn("aheadtb");

        System.out.println("ggaddServlet conn连接创建结束");

}

//Process the HTTP Get request

    public void service(HttpServletRequest request,

                        HttpServletResponse response) throws

            ServletException, IOException {

        boolean flag =false;

//boolean ggdel  =false;

       // String ggid=StringTool.gb2iso(request.getParameter("id"));

        String biaoti = StringTool.gb2iso(request.getParameter("biaoti"));

        String neirong =StringTool.gb2iso( request.getParameter("neirong"));

        String chuangjian = StringTool.gb2iso(request.getParameter("chuangjian"));

        Gonggao  gg = new Gonggao();

       flag =  gg.add(biaoti,neirong,chuangjian);

      // ggdel =gg.del(ggid);

 

   if(flag){

        RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/admin/gg_manage.jsp");

        rd.forward(request, response);

   }else

   {

       RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/admin/ggadderror.jsp");

       rd.forward(request, response);

}

}

//Clean up resources

    public void destroy() {

        try {

            conn.close();

            System.out.println("关闭连接");

        } catch (SQLException ex) {

        }}}

6.2删除公告信息

  删除公告也是通过编写ggdelservlet

package com.aheadedu.zyy;

import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

import java.util.*;

import java.sql.*;

public class ggdelServlet extends HttpServlet {

    private static final String CONTENT_TYPE = "text/html; charset=GBK";

    Connection conn = null;

    //Initialize global variables

    public void init() throws ServletException {

        com.aheadedu.zyy.DbTool dbtool = new com.aheadedu.zyy.DbTool();

        conn = dbtool.getConn("aheadtb");

        System.out.println("ggdelServlet conn连接创建结束");

}

//Process the HTTP Get request

    public void service(HttpServletRequest request,

                        HttpServletResponse response) throws

            ServletException, IOException {

 

        boolean ggdel  =false;

        String ggid=StringTool.gb2iso(request.getParameter("id"));

        Gonggao  gg = new Gonggao();

 

       ggdel =gg.del(ggid);

   if(ggdel){

        RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/admin/gg_manage.jsp");

        rd.forward(request, response);

   }else

   {

       RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/admin/ggadderror.jsp");

       rd.forward(request, response);

 

   }

 }

 

    //Clean up resources

    public void destroy() {

        try {

            conn.close();

            System.out.println("关闭连接");

        } catch (SQLException ex) {

        }

}

}

上一页  [1] [2] [3] [4] [5] 下一页

Copyright © 2007-2012 www.chuibin.com 六维论文网 版权所有