Login Form (index2.html)
<html>
<head>
<title>Login Form</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body bgcolor="96D2C2">
<form name="ask_1" method="get" action="index24.jsp">
Username: <input type="text" name="id11"/> <BR>
Password: <input type="password" name="id22" /> <BR>
<input type="submit" value="Login" /> <BR>
<BR>
</form>
<a href="index12.html"> Create an Account </a>
</body>
My JSP code in order to verify the login info and print to user success or not... (index24.jsp)`
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %>
<% int j=0; %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
Class.forName("com.mysql.jdbc.Driver");
String myDatabase = "jdbc:mysql://localhost:3306/mydb1?user=root&password=1234";
Connection myConnection = DriverManager.getConnection(myDatabase);
Statement myStatement = myConnection.createStatement();
String id11=request.getParameter("id11");
String id22=request.getParameter("id22");
String sqlString = "SELECT FROM users WHERE username='"+id11+"' AND password='"+id22+"' ";
ResultSet rs = myStatement.executeQuery(sqlString);
if(rs.next()) {
System.out.println("Success"); }
else {
System.out.println("Failed");
}
%>
</body>
</html>
The code given above is giving me the error, "The requested resource is not available.". Any suggestions and improvements to my code or edit are appreciated.
Finally the problem was the server (GlassFish)... i used Apache Tomcat and works properly...