public String validateUser(String inputUserid
throws SQLException
{
String returnString = null;
String dbUserid = "userid"; // 數據庫的用戶名
String dbPassword = "password" ; //數據庫的密碼
Class
Connection con = DriverManager
Statement stmt = con
String sql= "select USERID from USERTABLE where USERID =
ResultSet rs = stmt
if (rs
{
returnString = rs
}
stmt
con
return returnString ;
}
如何設置application 變量
application變量是對一個web application有效的全局變量
在JSP中
在引用application 變量時
servletContext application=getServletContext();
後面的一段函數是env
Welcome visitor:
如何防止IE緩存jsp文件
類似於asp中htmlencode函數的jsp函數
public static String asHTML(String text)
{
if (text == null)
return "";
StringBuffer results = null;
char[] orig = null;
int beg =
for (int i =
{
char c = text
switch (c){
case
case
case
case
case
if (results == null)
{
orig = text
results = new StringBuffer(len+
}
if (i > beg)
results
beg = i +
switch (c)
{
default: // case
continue;
case
results
break;
case
results
break;
case
results
break;
case
results
break;
}
break;
}
}
if (results == null)
return text;
results
return results
}
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20452.html