[table=600][tr][td]public String validateUser(String inputUserid, String inputPwd)
throws SQLException
{
String returnString = null;
String dbUserid = "userid"; // 数据库的用户名
String dbPassword = "password" ; //数据库的密码
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:myDriver", dbUserid , dbPassword );
Statement stmt = con.createStatement();
String sql= "select USERID from USERTABLE where USERID = '" + inputUserid + "' and PASSWORD = '" + inputPwd +"' ;" ;
ResultSet rs = stmt.executeQuery(sql);
if (rs.next())
{
returnString = rs.getString("USERID");
}
stmt.close();
con.close();
return returnString ;
}[/td][/tr][/table]
如何设置application 变量 application变量是对一个
web application有效的全局变量,在保存一些全局有效的值时非常有用。与session变量不同,application变量可以用application.getAttribute()和application.setAttribute()来访问。
在JSP中,可以自动引用application变量,指代当前的web 应用。
在引用application 变量时,必须使用同步。并且,需要测试一个application属性是否已经存在。请仔细研究下面的代码,在下面,设置了一个叫"change"的application 属性,保存一个整型值。关于在servlet中使用application变量,方法与下面的代码一致,不过,需要先说明一个application如下:
[table=600][tr][td]servletContext application=getServletContext();[/td][/tr][/table]
后面的一段函数是env.
java的片断,可以看看在servlet中如何使用application变量的。
");
pw.println("
Application Variables:");
pw.println("
");
}
%>
Welcome, visitor: [/td][/tr][/table]
如何防止IE缓存jsp文件 1.使用Java提供的方法,在jsp或者servlet中都可以
2.使用HTML标记,如下面:
类似于asp中htmlencode函数的jsp函数