JSP问题,一段看不懂的代码。
同学发给我一个JSP程序,在checklogin.jsp include tran.jsp
tran.jsp 的代码如下:
<%@page import= "java.io.*,java.util.*,java.text.SimpleDateFormat "%>
<%!
String tranc(String str){
String result= " ";
if(str!=null){
try{
result=new String(str.getBytes( "ISO-8859-1 "));
} catch(Unsupported
EncodingException e) {
System.out.println(e.toString());
}
return result;
} else
return result;
}
String trans(String str){
String result= " ";
if(str!=null){
try{
result=new String(str.getBytes( "gb2312 "));
} catch(UnsupportedEncodingException e) {
System.out.println(e.toString());
}
return result;
}else
return result;
}
java.sql.Date transqldate(int year,int month,int day){
Calendar cal=Calendar.getInstance();
GregorianCalendar calendar=new GregorianCalendar(year,month-1,day);
SimpleDateFormat f=new SimpleDateFormat( "yyyy-MM-dd ");
String date=f.format(calendar.getTime());
java.sql.Date t=null;
t=t.valueOf(date);
return t;
}
java.util.Date trandate(int year,int month,int day){
Calendar cal=Calendar.getInstance();
GregorianCalendar calendar=new GregorianCalendar(year,month-1,day);
SimpleDateFormat f=new SimpleDateFormat( "yyyy-MM-dd ");
String date=f.format(calendar.getTime());
java.sql.Date k=null;
java.util.Date t=k.valueOf(date);
return t;
}
String randomKey(int sLen) {
String base;
String temp;
int i;