jsp开发为什么不能运行javascript脚本?
检查登陆的jsp页面!代码如下:
<%@ page contentType= "text/html; charset=GBK " language= "java " import= "java.sql.*,java.util.*,java.io.* "%>
<html>
<head>
</head>
<body bgcolor= "white ">
<%
String userid=new String(request.getParameter( "id ").getBytes( "iso-8859-1 "));
String password=request.getParameter( "pwd ");
if((userid!=null)&(password!=null)){
out.print( " <script language= 'JavaScript '> alert( '帐号和密码不能为空! '); </script> ");
response.sendRedirect( "index.html ");
}
try{
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
Connection con=DriverManager.getConnection( "jdbc:odbc:myweb ", " ", " ");
Statement stmt=con.createStatement();
ResultSet rst=stmt.executeQuery( "select * from user_info where userid= ' "+userid+ " ' and password= ' "+password+ " ' ");
while(rst.next()){
session.setAttribute( "name ",rst.getString( "username "));
response.sendRedirect( "homepage.jsp ");
}
if(!rst.next()){
out.print( " <script language= 'JavaScript '> alert( '帐号或密码错误! '); </script> ");
response.sendRedirect( "index.html ");
}
rst.close();
stmt.close();
con.close();
}catch(Exception e){
e.printStackTrace();
}