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

王朝java/jsp·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

ntGBDP2002_Define.jsp

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

<%

/*

* GBDP2002新版, 注意使用的是cint.ntDB !!! ,支持INT

* 注意:本JSP被其他页面调用,不能产生额外的空格和回车

*

*/

file://全局变量定义

String globalTableName ;

String parentKey ="" ;

String parentValue ="" ;

String dbName = "mhoa";

ntDB ntP = new ntDB();

ntDB nt = new ntDB();

String sql ;

String sql_trans = "" ; file://用来插入后面的保存到数据库的sql语句中,使其中在事务之中间

String sql_TRANS_ERROR = ntDB.sql_TRANS_ERROR ;

boolean isPost = false ;

{

isPost = request.getMethod().equals("POST");

}

boolean isEdit = false ;

boolean isAdd = false ;

boolean isDelete = false ;

boolean isUpload = false ;

boolean uploaded = false ; file://表示已经上传完毕

boolean tableCreated = false ; file://表示数据库表已经建立

{

String contentType = request.getContentType();

if( contentType != null

&&

contentType.indexOf("multipart/form-data") != -1

)

isUpload = true;

}

boolean hasId = false;

boolean hasMasterId = false;

int maxReturnRows = 10000 ;

int id = 0 ; // 表示主记录id号,一般为1,2,3......,必须在ntGBDPUpload.jsp

// 中获取,因为当upload的情况无法从request中获取参数

int masterId = 0 ; // 同上

file://绝对路径

String realPath ; // like 'c:\a\'

{

realPath = getServletConfig().getServletContext().getRealPath("");

}

file://上传目录

String uploadDir;

{

uploadDir = realPath + "upload";

}

file://存放所有request的信息,使用它的原因是后面如果有upload的时候,

// request将没有任何参数和值,必须从upload中重新找到

java.util.Hashtable requestHt;

{

requestHt = new java.util.Hashtable();

Enumeration e = request.getParameterNames();

while( e.hasMoreElements() )

{

String s = (String)e.nextElement();

String sValue = request.getParameter(s);

requestHt.put( s , sValue );

}

}

file://upload

java.io.File mydir = null ;

SmartUpload mySmartUpload = null ;

if( isPost && isUpload )

{

mySmartUpload=new SmartUpload();

mySmartUpload.initialize(pageContext);//初始化

mySmartUpload.upload();//上传分析

Request smartRes = mySmartUpload.getRequest();

{

file://将request参数传入requestHt全局变量

Enumeration e = smartRes.getParameterNames();

while( e.hasMoreElements() )

{

String s = ((String)e.nextElement()).trim();

String sValue = (smartRes.getParameter(s)).trim();

requestHt.put( s , sValue );

}

}

}

%>

<%

isEdit = isPost && requestHt.get("edit")!=null ;

isAdd = isPost && requestHt.get("add")!=null ;

isDelete = requestHt.get("delete")!=null ;

// 这里当没有命令发出的时候,所有操作跳过

hasId = requestHt.get("id")!=null ;

id = 0 ;

if( requestHt.get("id")!=null )

id = Integer.parseInt( (String)requestHt.get("id") );

hasMasterId = requestHt.get("masterId")!=null ;

masterId = 0 ;

if( requestHt.get("masterId")!=null )

masterId = Integer.parseInt( (String)requestHt.get("masterId") );

%>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航