<%!
File: // get the machine name or IP address
String get_Myhostname (javax. servlet. http. HttpServletRequest request ){
String myhostname = null;
Try {
Myhostname = request. getRemoteHost ();
Myhostname = myhostname. toUpperCase ();
} Catch (Exception e ){}
Return myhostname;
}
File: // process an empty string
String dealNull (String str ){
String returnstr = null;
If (str = null) returnstr = "";
Else returnstr = str;
Return returnstr;
}
File: // process empty objects
Object dealNull (Object obj ){
Object returnstr = null;
If (obj = null) returnstr = (Object )("");
Else returnstr = obj;
Return returnstr;
}
Int dealEmpty (String s ){
S = dealNull (s );
If (s. equals ("") return 0;
Return Integer. parseInt (s );
}
String replace (String str, String substr, String restr ){
String [] tmp = split (str, substr );
String returnstr = null;
If (tmp. length! = 0 ){
Returnstr = tmp [0];
For (int I = 0; I <tmp. length-1; I ++)
Returnstr = dealNull (returnstr) + restr + tmp [I + 1];
}
Return dealNull (returnstr );
}
String htmlEncode (String txt ){
Txt = replace (txt ,"&","&");
Txt = replace (txt ,"&","&");
Txt = replace (txt ,""",""");
Txt = replace (txt ,""",""");
Txt = replace (txt, "<", "<");
Txt = replace (txt, "<", "<");
Txt = replace (txt, ">", "> ");
Txt = replace (txt, ">", "> ");
Txt = replace (txt ,"","");
Txt = replace (txt ,"","");
Return txt;
}
String unHtmlEncode (String txt ){
Txt = replace (txt ,"&","&");
Txt = replace (txt ,""",""");
Txt = replace (txt, "<", "<");
Txt = replace (txt, ">", "> ");
Txt = replace (txt ,"","");
Return txt;
}
File: // ALERT Function
Void sAlert (String title, String msg, String focus, JspWriter out ){
Try {
Out. println ("<" script language = javascript "> ");
Out. println ("alert (" "+ title +" "+"
"+" "+ Replace (msg,", "),", ") + "");");
Out. println (focus );
Out. println ("");
} Catch (Exception e) {System. out. println (e );}
}
File: // CONFIRM Function
Void sConfirm (String title, String msg, String location, JspWriter out ){
Try {
Out. println ("<" script language = javascript "> ");
Out. println ("if (confirm (" "+ title +" "+"
"+" "+ Replace (msg," ",") + "")){");
Out. println ("var d = (new Date (). toString ();");
Out. println (location + "+ d ;");
Out. println ("}");
Out. println ("parent.doc ument. form1.text1. select ();");
Out. println ("");
} Catch (Exception e ){}
}
File: // get the string length
Int getStringLength (String s ){
Int p = 0;
Try {
Int iLength = 0;
Int irealLength = 0;
Int j = 0;
P = s. getBytes ("Shift_JIS"). length;
} Catch (java. io. UnsupportedEncodingException e ){}
Return p;
}
Void formatString (String s, int B, JspWriter out ){
B --;
String t = "";
Try {
Int leng = getStringLength (s );
Int j = 0;
If (leng> B ){
For (int I = 1; I <= B; I ++ ){
T = s. substring (0, I );
If (t. getBytes ("Shift_JIS"). length <= B ){
J ++;
} Else break;
}
File: // j = j + 1;
File: // System. out. println ("B =" + B + "----" + "j =" + j );
For (int I = 0; I <j; I ++ ){
If (s. substring (I, I + 1). equals (""))
Out. print ("");
If (! S. substring (I, I + 1). equals (""))
Out. print (htmlEncode (s. substring (I, I + 1 )));
}
If (s. substring (0, j). getBytes ("Shift_JIS"). length = B ){
Out. print ("| ");
} Else {
Out. print ("| ");
}
} Else {
For (int I = 0; I <B-leng; I ++)
T = t + "";
For (int I = 0; I <s. length (); I ++ ){
If (s. substring (I, I + 1). equals (""))
Out. print ("");