%@ page language="java" import="java.sql.*" contentType="text/html;charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
My JSP 'check.jsp' starting page
<%
request.setCharacterEncoding("utf-8");
String users=request.getParameter("inputUser");
String pass=request.getParameter("inputPassword");
boolean flag=false;
PreparedStatement sql=null;
ResultSet rs=null;
Connection conn=null;
%>
<%
String driver = "com.mysql.jdbc.Driver";
String url="jdbc:mysql://localhost:3306/db_school";
String use = "root";
String password = "";
Class.forName(driver);
conn= DriverManager.getConnection(url,use,password);
sql =conn.prepareStatement("select * from user where userName=? and password=?");
sql.setString(1,users);
sql.setString(2,pass);
rs=sql.executeQuery();
if (rs.next()) {
flag=true;
}
rs.close();
sql.close();
conn.close();
%>
<% if (flag==true){ %>
<%}
else
if (flag==false){
%>
<%} %>