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

📄 query.java

📁 java web 开发,Java Xml 编程指南书籍源码
💻 JAVA
字号:
// servlet Query, which really doesn't know what it's doing;
// it sets up a DBHandler, 
// it is aware that "InitDBHandler" means it should start up
// a new session containing a DBHandler initialized with the 
// environment provided by the servlet request; it is aware
// that LOGOUT means it should kill the session. All the
// information about what queries are to be used, and how to
// present the results, comes from Somewhere Else: in this
// case, the queries are defined in the initdbhandler html
// form, and each query can refer to an html template file
// for output.


import javax.servlet.*;  // communicate with client
import javax.servlet.http.*; 

import MyNa.utils.Logger;  // saves admin/debug info to file

import MyNa.utils.Env;   // basic package
import MyNa.utils.MiscFile;   // basic package
import java.util.Enumeration;   // 
import MyNa.utils.DBHandler;   // communicate with database
import java.sql.SQLException;   // thrown by LookerUpper

import MyNa.utils.HtmlWrapper; // sends HTML to client.
import java.io.IOException; // thrown by HtmlWrapper
import MyNa.utils.MiscDate; // for logging.


public class Query extends HttpServlet { 
  Logger lg;

  public void doGet (HttpServletRequest req, 
                     HttpServletResponse res)
          throws ServletException, IOException{
    doPost(req,res);
  }

  public void doPost (HttpServletRequest req, 
                     HttpServletResponse res)
          throws ServletException, IOException{
    res.setContentType("text/html");
    HtmlWrapper W=new HtmlWrapper(res.getWriter());
    lg=new Logger();
    lg.logIt("query.doPost at "+MiscDate.todaysDate());
    try{
      Env E=new Env(req);
      DBHandler dbH=new DBHandler(E);
      E=dbH.getQueryResult(E);
      E.remove("dbHandler");
      dbH.close();
    lg.logIt("query.doPost closed handler");
      W.wrapEnvResultPage(E);
    lg.logIt("query.doPost wrapped resultpage");
    }catch(Exception ex){
      W.wrapPage("doPost failure",""+ex);}
  }

}

⌨️ 快捷键说明

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