「字符串文字未正確關閉的雙引號」無法找到雙引號來關閉字符串
我遇到了上述問題。我已經通過我的代碼搜索了高和低,我仍然無法識別錯誤。它說,錯誤是在第12行
這裏是我的代碼中發現: http://pastebin.com/WgD3ApR0
我在JSP
編碼。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%
response.addHeader("Cache-Control","no-cache");
response.addHeader("Pragma","no-cache");
response.addHeader("Expires","0");
// Login variables //
String username = request.getParameter("username");
String password = request.getParameter("password");
// SQL login variables //
// Role variables //
// Encryption of session ID //
String sessId = "" + (new java.util.Random()).nextInt(1000);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String conURL= "jdbc:odbc:HOD_DATA";
Connection con = DriverManager.getConnection(conURL);
Statement st = con.createStatement();
String query = "select user_group from login
where username = '"+username+"'
and password = '"+password+"'
";
ResultSet rs = st.executeQuery(query);
Boolean result = rs.next();
// Might have to pass the login details over to the other pages //
if(result == true){
// Ashton //
if(rs.getString("user_group").equals("admin")){
String url = response.encodeURL("Test.jsp?sessId=" + sessId);
response.sendRedirect(url);
}
// Joseph //
else if(rs.getString("user_group").equals("clerk")){
String url = response.encodeURL("ClerkPage.jsp?sessId=" + sessId);
response.sendRedirect(url);
}
// Gaurav //
else if(rs.getString("user_group").equals("customer")){
String url = response.encodeURL("HomePage.jsp?sessId=" + sessId);
response.sendRedirect(url);
}
// Jiong xu //
else if(rs.getString("user_group").equals("sales")){
String url = response.encodeURL("SalesPage.jsp?sessId=" + sessId);
response.sendRedirect(url);
}
// Wen jie //
else if(rs.getString("user_group").equals("operations")){
String url = response.encodeURL("OperationsPage.jsp?sessId=" + sessId);
response.sendRedirect(url);
}
}
else {
response.sendRedirect("LoginPage.jsp"); // If the above fails, redirect to login //
}
rs.close();
st.close();
con.close();
%>
</body>
</html>
你相信'SQL注入'嗎? – 2014-12-03 12:59:11