作者:xiaoyou
出处: www.csdn.com
<%!
stc_rsyb_name stcrsyname1[];
stc_syb_inf stcsybinf1[];
%>
<%/*
string p = (string) session.getvalue("access");
if (p==null || !p.equals("1")) {
response.sendredirect("error.htm");
return;
}*/
%>
<%!
file://得到机器名字或ip
string get_myhostname(javax.servlet.http.httpservletrequest request){
string myhostname = null;
try{
myhostname = request.getremotehost();
myhostname = myhostname.touppercase();
}catch(exception e){}
return myhostname;
}
file://处理空字符串
string dealnull(string str) {
string returnstr = null;
if (str == null) returnstr = "";
else returnstr = str;
return returnstr;
}
file://处理空对象
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 + "/" + /"//r//n/" + /"" + replace(replace(msg,"''","'"),"/"","///"") +"/");");
out.println(focus);
out.println("</script>");
} 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 + "/" + /"//r//n/" + /"" + replace(msg,"/"","///"") + "/")){" );
out.println("var d = (new date()).tostring();");
out.println(location + "+ d;");
out.println("}");
out.println("parent.document.form1.text1.select();");
out.println("</script>");
} catch (exception e) { }
}
file://得到字符串长度
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("|");
&n
出处: www.csdn.com
<%!
stc_rsyb_name stcrsyname1[];
stc_syb_inf stcsybinf1[];
%>
<%/*
string p = (string) session.getvalue("access");
if (p==null || !p.equals("1")) {
response.sendredirect("error.htm");
return;
}*/
%>
<%!
file://得到机器名字或ip
string get_myhostname(javax.servlet.http.httpservletrequest request){
string myhostname = null;
try{
myhostname = request.getremotehost();
myhostname = myhostname.touppercase();
}catch(exception e){}
return myhostname;
}
file://处理空字符串
string dealnull(string str) {
string returnstr = null;
if (str == null) returnstr = "";
else returnstr = str;
return returnstr;
}
file://处理空对象
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 + "/" + /"//r//n/" + /"" + replace(replace(msg,"''","'"),"/"","///"") +"/");");
out.println(focus);
out.println("</script>");
} 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 + "/" + /"//r//n/" + /"" + replace(msg,"/"","///"") + "/")){" );
out.println("var d = (new date()).tostring();");
out.println(location + "+ d;");
out.println("}");
out.println("parent.document.form1.text1.select();");
out.println("</script>");
} catch (exception e) { }
}
file://得到字符串长度
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("|");
&n
闽公网安备 35060202000074号