xml2dbs.java

来自「java web 开发,Java Xml 编程指南书籍源码」· Java 代码 · 共 59 行

JAVA
59
字号
// servlet Xml2DBS, which sets up commands for the
// Xml2DBTables class

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.EnvServlet; // for setStr.
import MyNa.utils.MiscFile;   // basic package

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



public class Xml2DBS extends EnvServlet { 
  String filePath = "MyNa/Xml2DBS/"; // C:\JRun\jsm-default\MyNa\Xml2DBS
  String topFileName = "top.htm";  // these are not used now, but may be
  String ctlFileName = "ctl.htm"; // future template/session controls.
  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(); 
    try{
      Env E=new Env(req);
      String myURL=res.encodeURL(req.getRequestURI());
      E.put("xmlServlet",myURL);
      setStr(E,"filePath","",filePath);
      String theXmlData=E.getStr("XmlData");
      if(null==theXmlData){
        W.wrapPage("Xml2DBS error","no Xml Data Source specified");
        return;
        }
   Xml2DBTables x2DB=new Xml2DBTables(theXmlData);
   x2DB.doIt();
   W.wrapPage("Xml2DBS ","done with "+theXmlData);
    }catch(Exception ex){
      W.wrapPage("doPost failure",""+ex);}
  }


}


⌨️ 快捷键说明

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