一种新的编程思路(下):附 ntGBDP2002.jsp

类别:Java 点击:0 评论:0 推荐:

ntGBDP2002.jsp

---------------------------------------------------------------------

<%@page contentType="text/html;charset=GBK" %>
<%@page import="java.lang.*,java.net.*,java.sql.*" %>
<%@page import="java.text.*,java.util.*" %>
<%@page import="cint.ntDB" %>
<%@page import="com.jspsmart.upload.*"%>
<%@page session="true" %>
<%@page errorPage="error.jsp"%>

<%
file://上传文件
if( isUpload && isPost && !uploaded )
{
  mydir = new java.io.File( uploadDir ); file://uploadDir is GlobalVar
  if( !mydir.exists() )
    if( !mydir.mkdir() )
      throw new Exception("创建上传文件夹失败![" + uploadDir + "]");
   
  Files files = mySmartUpload.getFiles();
  String sfilename ="";
 
  try{
    for(int i=0;i<files.getCount();i++){
      com.jspsmart.upload.File file = files.getFile(i);
      sfilename = file.getFileName();
      if( sfilename == null ) sfilename = "";
      String s = sfilename ;
      file://文件另存
      //    20021231121212123_abc.zip
      if( sfilename.length() <= (255-18-1) )
      {
        s = (new SimpleDateFormat("yyyyMMddHHmmssSSS")).format(new java.util.Date())
            + "_"
            + sfilename ;
      }     
      file.saveAs( uploadDir
        + System.getProperty("file.separator")
        + s );
      //
      if( !s.trim().equals("") )
        requestHt.put( "uploadFileName"+i , s );
    } file://end for
 
    file://try{
      file://mySmartUpload.save(uploadDir);
  }catch(Exception e){
    throw new Exception("上传文件失败!"+ e.getMessage() );
  }
 
  uploaded = true ;
} // end if upload
%>

<%
  file://全局数据->requestHt
  requestHt.put("globalTableName",globalTableName);
  requestHt.put("dbName",dbName);
  requestHt.put("parentKey",parentKey);
  requestHt.put("parentValue",parentValue);
  requestHt.put("sql_trans",sql_trans);
%>

<%
  if( !tableCreated )
  {
    nt.createTable( dbName , globalTableName );
    tableCreated = true ;
  } 
%>

<%--
  file://以后调用保存到数据库
  nt.toDB( requestHt );
--%>

本文地址:http://com.8s8s.com/it/it18256.htm