0
我在Java EE的初學者,我在創建登錄page.I作出了共同的登錄頁面,通過該工程師可以登錄到他/她的account.Engineers用戶名有問題開始與「ENGG」。所以,我已經對輸入錯誤的用戶名,如「uname100」,這是不存在於我的表下面的代碼並獲得IllegalStateException異常錯誤。IllegalStateException異常錯誤
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import sun.java2d.pipe.GeneralCompositePipe;
import accessdb.Dao;
import accessdb.Getset;
/**
* Servlet implementation class AdminLogIn
*/
public class AdminLogIn extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @return
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
try {
String username=request.getParameter("username");
String password=request.getParameter("password");
Getset g=new Getset();
Dao dao=new Dao();
g.setuname(username);
String newuname=username.substring(0,4);
// System.out.println(""+username);
if(newuname.equals("engg"))
{
ResultSet rs=dao.EnggLogInUseridCheck(g);
System.out.println(""+newuname);
while(rs.next())
{
String uname=rs.getString("uname");
System.out.println(""+uname);
if(uname.equals(username))
{
g.setuname(username);
System.out.println(""+username);
System.out.println(""+uname);
ResultSet rs1=dao.EnggLogInPasswordCheck(g);
while(rs1.next())
{
String password1=rs1.getString("password");
if(password1.equals(password))
{
System.out.println(""+password1);
response.sendRedirect("engghome.jsp");
break;
}
else
{
response.sendRedirect("login.jsp");
return;
}
}
break;
}
else
{
response.sendRedirect("login.jsp");
return;
}
}
}
else
{
response.sendRedirect("login.jsp");
return;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
和異常的堆棧跟蹤? – 2012-07-08 20:55:57