日期:2014-05-17  浏览次数:20862 次

asp常用语句对应的JSP语句是什么?
asp常用语句对应的JSP语句是什么?
我们做oracle ebs二次开发,用的是asp
现在想转为jsp, 我把常用到的贴出来,看看哪位高手能转成jsp的代码?
1.显示信息response.write()
2.null处理
 if isnull(rowdata(r,20)) then
  rowdata(r,20)=0
 end if 
2.遍历数组
r_wef6001=1
do while rowdata_wef6001(r_wef6001,0) <>""
r_wef6001=r_wef6001+1
loop
rowdata_wef6001(r_wef6001,0)为数组
3.从数据库中取值:
方法一。用 do while
strSQL=readSQL("xina005L_mw.txt")
rs.open strSQL,cn
r=1
do while not rs.eof
  rowdata(r,0)=rs.fields("批號")
  rs.movenext
  r=r+1
loop
rs.close

方法二。用if
 rs.open strsql,cn
  if not rs.eof then
  countSum1=rs.fields("C")
  end if
  rs.close
4.调用存储过程
dim objCmd
set rs = Server.CreateObject("ADODB.RecordSet") 
set objCmd =server.createobject("adodb.command")  
objCmd.ActiveConnection= cn
objCmd.CommandType=adCmdStoredProc
objCmd.CommandText="update_total_quantity" 

objCmd.execute
set rs= objCmd.execute()
5.连接数据库
dim objCmd
set rs = Server.CreateObject("ADODB.RecordSet") 
set objCmd =server.createobject("adodb.command")  
objCmd.ActiveConnection= cn
objCmd.CommandType=adCmdStoredProc
objCmd.CommandText="update_total_quantity" 

objCmd.execute
set rs= objCmd.execute()

6.两个日期的时间间隔
c="20110601"
d="20110829" 

c=left(c,4)&"-"&mid(c,5,2)&"-"&right(c,2)
d=left(d,4)&"-"&mid(d,5,2)&"-"&right(d,2)

response.write "c、d两个日期的时间间隔為" & DateDiff("d",c,d) & "<br>"

7。循环语句
While condition
[statements]
Wend
不停地執行語句statements 直到條件condition為True。


























------解决方案--------------------
1.显示信息:
out.println("内容");

2.null处理:
String s = null;
if(s == null)
{
s = "ABC";
}

3.从数据库中取值:
List list = new ArrayList();
try
{
//比如MySQL,需要导入MySql的jar包
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/flmsite?useUnicode=true&characterEncoding=gbk","root","");
PreparedStatement pstmt = null;
ResultSet rs = null;
pstmt = conn.prepareStatement("SELECT * FROM TABLE");
rs = pstmt.executeQuery();
while(rs.next())
{
//取第一列,添加数组
list.add(rs.getString(1));
}
rs.close();
pstmt.close();
conn.close();
}
catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
list = null;
}
4.调用存储过程
try
{
//比如MySQL,需要导入MySql的jar包
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/flmsite?useUnicode=true&characterEncoding=gbk","root","");
PreparedStatement pstmt = null;
pstmt = conn.prepareCall("{ call update_total_quantity(?) }"); 
pstmt.setString(1, "参数"); 
pstmt.execute();
pstmt.close();
conn.close();
}
catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}


5.连接数据库,需要导入MySql的jar包
//比如MySQL
Class.forName("com.mysql.jdbc.Driver&qu