⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hyxw3servlet.java~37~

📁 c++通信编程学习1
💻 JAVA~37~
字号:
package com.j2ee.servlet.news;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import com.j2ee.func.news.NewsFunc;
import java.sql.SQLException;

public class Hyxw3Servlet extends HttpServlet {
    public Hyxw3Servlet() {
        try {
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

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

    //Initialize global variables
    public void init() throws ServletException {
    }

    //Process the HTTP Get request
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws
            ServletException, IOException {
        String str=request.getParameter("id");
       Vector vctgn=new Vector();
       Vector vctgj=new Vector();
       Vector vctzh=new Vector();
       Vector vctqy=new Vector();
       Vector vcthy=new Vector();
       String pagei=request.getParameter("pageno");
       int count=0,pagesize=0;
       int page=Integer.parseInt(pagei);



        if(str.equals("gnxw")){
            NewsFunc nfgn = new NewsFunc("国内新闻",page,2);
            try {
                count = nfgn.SelectCount();
            } catch (SQLException ex1) {
            }
            try {

                vctgn = nfgn.SelectNews();
            } catch (SQLException ex) {
            }
            try {
                pagesize = nfgn.getPagesize();
            } catch (SQLException ex2) {
            }
            request.setAttribute("type", "国内新闻");
            request.setAttribute( "vct",vctgn);
        }
        else if(str.equals("hyfx")){
            NewsFunc nfhy = new NewsFunc("行业分析",page,2);
            try {
               count = nfhy.SelectCount();
           } catch (SQLException ex1) {
           }
        try {
            pagesize = nfhy.getPagesize();
        } catch (SQLException ex5) {
        }

            try {

                vcthy = nfhy.SelectNews();
            } catch (SQLException ex) {
            }
            request.setAttribute("type", "行业分析");
            request.setAttribute( "vct",vcthy);
        }
        else if(str.equals("gjxw")){
            NewsFunc nfgj = new NewsFunc("国际新闻",page,2);
            try {
               count = nfgj.SelectCount();
           } catch (SQLException ex1) {
           }
        try {
            pagesize = nfgj.getPagesize();
        } catch (SQLException ex6) {
        }

            try {

                vctgj = nfgj.SelectNews();
            } catch (SQLException ex) {
            }
            request.setAttribute("type", "国际新闻");
            request.setAttribute( "vct",vctgj);
        }
        else if(str.equals("qydt")){

          NewsFunc nfqy = new NewsFunc("企业动态",page,2);
          try {
                  count = nfqy.SelectCount();
              } catch (SQLException ex1) {
              }
            try {
                pagesize = nfqy.getPagesize();
            } catch (SQLException ex7) {
            }

          try {

                vctqy = nfqy.SelectNews();
            } catch (SQLException ex) {
            }
            request.setAttribute("type", "企业动态");
            request.setAttribute( "vct",vctqy);
        }
        else if(str.equals("zhxx")){
            NewsFunc nfzh = new NewsFunc("展会信息",page,2);
            try {
               count = nfzh.SelectCount();
           } catch (SQLException ex1) {
           }

        try {
            pagesize = nfzh.getPagesize();
        } catch (SQLException ex8) {
        }

            try {
                vctzh=nfzh.SelectNews();
            } catch (SQLException ex) {
            }
            request.setAttribute("type", "展会信息");
            request.setAttribute("vct",vctzh);
        }

        Vector vctzxxw=null;
        Vector vcttjxw=null;
        NewsFunc nfzxxw=new NewsFunc();
        try {
            vctzxxw = nfzxxw.selectTalltitle();
        } catch (SQLException ex3) {
        }
       NewsFunc nftjxw=new NewsFunc();
    try {
        vcttjxw = nftjxw.SelectTjnews();
    } catch (SQLException ex4) {
    }

       request.setAttribute("pagesize",Integer.toString(pagesize));
       request.setAttribute("count",Integer.toString(count));
       request.setAttribute("pageno",pagei);
       request.setAttribute("vcttjxw",vcttjxw);
       request.setAttribute("vctzxxw",vctzxxw);
        request.getRequestDispatcher("hyxw_3.jsp").forward(request,response);


    }

    //Process the HTTP Post request
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws
            ServletException, IOException {
        doGet(request, response);
    }

    //Clean up resources
    public void destroy() {
    }

    private void jbInit() throws Exception {
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -