what happen to my login page

<%@ page import="java.util.*" %>

<%

String username=request.getParameter("username");

String password=request.getParameter("password");

//String status=request.getParameter("status");

session.setAttribute("theName", username );

out.println(status);

try{

Class.forName("com.mysql.jdbc.Driver");

}

catch (Exception E){

out.println("Unable to load driver.");

E.printStackTrace();

}

try{

Connection C = DriverManager.getConnection("jdbc:mysql://localhost/attendance","root","");

Statement S = C.createStatement();

Statement S2=C.createStatement();

ResultSet rs=S.executeQuery("Select * from login");

while(rs.next()){

String id= rs.getString("id");

String password2=rs.getString("password");

String status=rs.getString("status");

if (id.equals(username) && password2.equals(password) && status.equals("1"){

%>

<jsp:forward page="lec_page.jsp"/>

<%

}elseif(id.equals(username) && password2.equals(password) && status.equals("2")){

%>

<jsp:forward page="stu_page.jsp"/>

<%

}

else{

%>

<jsp:forward page="main.jsp">

<%}

}

rs.close();

C.close();

}

catch (Exception E){

out.println("SQLException: " + E.getMessage());

}

[2688 byte] By [albert85a] at [2007-11-26 22:31:11]
# 1
What is your question? Couldnt get any idea of ur problem
SMS_CVa at 2007-7-10 11:36:34 > top of Java-index,Java Essentials,Java Programming...
# 2
If you have attached the entire content of the jsp file, I think you have missed%>at the end of file.
rym82a at 2007-7-10 11:36:34 > top of Java-index,Java Essentials,Java Programming...
# 3

i get this kind of error when i login

org.apache.jasper.JasperException: /process2.jsp(44,0) Expecting "jsp:param" standard action with "name" and "value" attributes

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)

org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)

org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)

javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

albert85a at 2007-7-10 11:36:34 > top of Java-index,Java Essentials,Java Programming...
# 4
change<jsp:forward page="main.jsp">to<jsp:forward page="main.jsp"/>
rym82a at 2007-7-10 11:36:34 > top of Java-index,Java Essentials,Java Programming...
# 5
if you don't put a /, it expect you pass some parameter to the page you forwarding<jsp:forward page="main.jsp"><jsp:param name="user" value="someone"/></jsp:forward>
rym82a at 2007-7-10 11:36:34 > top of Java-index,Java Essentials,Java Programming...
# 6

there are many errors in your code. In addition, you should have used a servlet for the authentication (db access). Jsp show only the input/result data whereas the servlets are used for processing data (logic, db access).

Here is the code of the jsp I've corrected:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>

<%@ page import="java.util.*"%>

<%@page import="java.sql.*"%>

<%

String username = request.getParameter("username");

String password = request.getParameter("password");

//String status=request.getParameter("status");

session.setAttribute("theName", username);

String id = null;

String password2 = null;

String status = null;

//out.println(status);

try {

Class.forName("com.mysql.jdbc.Driver");

} catch (Exception E) {

out.println("Unable to load driver.");

E.printStackTrace();

}

try {

Connection C = DriverManager.getConnection("jdbc:mysql://localhost/attendance", "root", "");

Statement S = C.createStatement();

Statement S2 = C.createStatement();

ResultSet rs = S.executeQuery("Select * from login");

while (rs.next()) {

id = rs.getString("id");

password2 = rs.getString("password");

status = rs.getString("status");

}

rs.close();

C.close();

}

catch (Exception E) {

out.println("SQLException: " + E.getMessage());

}

if (id.equals(username) && password2.equals(password) && status.equals("1")) {

%>

<jsp:forward page="lec_page.jsp">

<jsp:param name="YOUR_PARAM_NAME" value="YOUR_PARAM_VALUE"/>

</jsp:forward>

<%

} else if (id.equals(username) && password2.equals(password) && status.equals("2")) {

%>

<jsp:forward page="stu_page.jsp">

<jsp:param name="YOUR_PARAM_NAME" value="YOUR_PARAM_VALUE"/>

</jsp:forward>

<%

} else {

%>

<jsp:forward page="main.jsp">

<jsp:param name="YOUR_PARAM_NAME" value="YOUR_PARAM_VALUE"/>

</jsp:forward>

<%

}

%>

java_2006a at 2007-7-10 11:36:34 > top of Java-index,Java Essentials,Java Programming...
# 7
my program should be compare the condition if not match with 1st condition, it will check the else if i set the status inside the database but the program just can detect the 1st condition but cannot detect condition 2
albert85a at 2007-7-10 11:36:34 > top of Java-index,Java Essentials,Java Programming...
# 8
did you read the code I posted ?
java_2006a at 2007-7-10 11:36:34 > top of Java-index,Java Essentials,Java Programming...
# 9
this code made me go blind sadfdsafadslkjldsajljfa lkdsasfs!!Sdafaf
mkoryaka at 2007-7-10 11:36:34 > top of Java-index,Java Essentials,Java Programming...
# 10
make some println statements before jump into the test casesIt didn't fall into the else if because the conditions didn't match
rym82a at 2007-7-10 11:36:34 > top of Java-index,Java Essentials,Java Programming...