Help JSP Loging using session

Can anybody help me out with this code. I am trying to create a login page for JSP using session but it's not working...

this is the code:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page language ="java" import = "*" import = "java.lang.*" import = "java.sql.*" %>

<%@taglib uri="" prefix="c"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

JSP Page

Div.Shade{ background:azure; border-top:1px solid darkcyan;border-bottom:1px solid darkcyan; width: 300px; height:50px;float: left}

<% try

Connection myConn;
String strUsername = request.getParameter("username");
String strPassword = request.getParameter("password");

myConn =DriverManager.getConnection("jdbc:odbc:RoomSchedule");

Statement myStatement = myConn.createStatement ();

String strSQL = "SELECT [userID], [password] FROM Administrator";

ResultSet myResult = myStatement.executeQuery(strSQL);

String strUser = myResult.getString("userID");
String strPass = myResult.getString("password");

if(strUsername.equals(strUser) && strPassword.equals(strPass))
session.setAttribute("authorized", "yes");
out.println("Login Successful!");
//invalid login
session.setAttribute("authorized", "no");
out.println("Login Fail!");

catch(Exception e){ }

This example uses JSTL, uncomment the taglib directive above.
To test, display the page like this: index.jsp?sayHello=true&name=Murphy
<c:if test="${param.sayHello}">

Hello ${}!



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!