您的位置:程序门 -> java -> web 开发



jsp中servlet显示空白页


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


jsp中servlet显示空白页
发表于:2007-09-20 23:10:04 楼主
我在做jsp程序中,做了一个servlet程序,以前可以正常显示,现在就是出现一个空白页,也没有报错,jsp网页正常显示
发表于:2007-09-21 01:26:191楼 得分:0
你这样说,鬼大爷知道你哪里出了问题!
最大的可能就是电脑坏了,我建议换台新的,不最好,但求最贵的那种
发表于:2007-09-21 08:36:192楼 得分:0
先把你顶一下   楼主是隔了多久发现不好用的阿?
发表于:2007-09-21 08:45:163楼 得分:0
可能是缓存问题,你把ie缓存和项目的jsp编译后的文件都删除后重试看看
发表于:2007-09-21 09:47:454楼 得分:0
你仔细看看是不是有异常了,
发表于:2007-09-21 17:03:525楼 得分:0
package   login;  
import   java.io.*;  
import   java.sql.*;  
import   javax.servlet.*;  
import   javax.servlet.http.*;  
public   class   loginservlet   extends   httpservlet   implements   servlet{  
public   loginservlet()  
{  
super();  
}  
protected   void   doget(httpservletrequest   request,httpservletresponse   response)throws   servletexception,ioexception  
{  
response.setcontenttype( "text/html ");  
string   result= " ";  
string   strusername=request.getparameter( "txtusername ");  
string   strpassword=request.getparameter( "txtpassword ");  
resultset   rs=null;  
statement   stmt=null;  
connection   conn=null;  
printwriter   out=response.getwriter();  
//out.println( " <html> <body> ");  
//out.println( " <h1> 1 <hi> ");  
//out.println( " </html> </body> ");  
if   ((strusername== " ") ¦ ¦(strusername.equals( " ")) ¦ ¦(strusername.length()> 20))  
{  
result= "请输入用户名(不超过20个字符!)! ";  
request.setattribute( "error_username ",   result);  

response.sendredirect( "login.html ");  
}  
if   ((strpassword== " ") ¦ ¦(strpassword.equals( " ")) ¦ ¦strpassword.length()> 20)  
{  
result= "请输入密码(不超过20个字符!)! ";  
request.setattribute( "error_password ",   result);  

response.sendredirect( "login.html ");  
}  
try{class.forname( "com.microsoft.jdbc.sqlserver.sqlserverdriver ");}  
catch(   classnotfoundexception   e)  
{   e.printstacktrace();}  


try{  
conn=drivermanager.getconnection( "jdbc:microsoft:sqlserver://127.0.0.1;databasename=jsp ", "sa ", "123456 ");  
string   sql= "select   *   from   userinfo   where   name= ' "+strusername+ " '   and   pwd= ' "+strpassword+ " ' ";  
stmt=conn.createstatement();  
rs=stmt.EXECutequery(sql);  

if(rs.next())  
{  
out.println( " <html> <body> ");  
out.println( " <h1> 1 <hi> ");  
out.println( " </html> </body> ");  
request.getsession(true).setattribute( "username ",strusername   );  
response.sendredirect( "success.jsp ");  
}  
else  
{  
out.println( " <html> <body> ");  
out.println( " <h1> 2 <hi> ");  
out.println( " </html> </body> ");  
response.sendredirect( "failure.jsp ");  
}  


}  
catch(sqlexception   e)  
{  
e.printstacktrace();  
}  
catch(exception   e)  
{  
e.printstacktrace();  
}  
finally  
{  
try{  
if(rs   !=null)  
{rs.close();}  
if(stmt   !=null)  
{stmt.close();}  
if(conn!=null)  
{conn.close();}  
}  
catch(sqlexception   e)  
{  
e.printstacktrace();  
}  
}  

}  
public   void   dopost(httpservletrequest   request,httpservletresponse   response)throws   servletexception,ioexception  
{  
doget(request,response);  
}  
}


快速检索

最新资讯
热门点击