clonmelog
asked on
URGENT: unknown error with login page
Hi,
Im attempting to create a login in jsp with the following form and jsp page to process it....
home.jsp:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<br>
<br>
<head>
<title>Momentum Marketing Intranet</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../ROOT/Momentum/tex t.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {font-size: 14px}
.style2 {
font-family: "Times New Roman", Times, serif;
font-size: 16px;
}
-->
</style>
</head>
<body bgcolor="#FFFFFF">
<table width="770" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">
<tr>
<td bgcolor="#FFFFFF"><table width="770" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><a href="../ROOT/Momentum/ind ex.jsp"><i mg src="../ROOT/Momentum/mom_ logo.gif" width="256" height="74" border="0"></a></td>
<td width="411"> </td>
</tr>
<tr>
<td width="359"><img src="../ROOT/Momentum/left bar.gif" width="359" height="39"></td>
<td align="right" bgcolor="336CA1"> </t d>
</tr>
<tr>
<td colspan="2"><img src="../ROOT/Momentum/topb ar.gif" width="770" height="69"></td>
</tr>
<tr>
<td colspan="2">
<table width="100%" border="0" cellspacing="0" cellpadding="0" background="../ROOT/Moment um/but_bg. gif">
<tr>
<td align="right"><img src="../ROOT/Momentum/spac er.gif" width="15" height="23"><img src="../ROOT/Momentum/spac er.gif" width="15" height="23"><img src="../ROOT/Momentum/spac er.gif" width="15" height="23"><img src="../ROOT/Momentum/spac er.gif" width="15" height="23"><img src="../ROOT/Momentum/spac er.gif" width="15" height="23"><img src="../ROOT/Momentum/spac er.gif" width="45" height="23"></td>
</tr>
</table>
</td>
</tr>
</table>
<table width="770" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="167" rowspan="3" valign="top" bgcolor="8FBEE8"> </td>
<td colspan="2" align="center"><table width="95%" border="0" cellpadding="5" cellspacing="0" class="text">
<tr>
<td class="text"><font color="#000000"><span class="style1"><br>
<span class="style2">Welcome to the Momentum Marketing company Intranet. Please authenticate yourself with our database to access the administration section. </span></span><br>
<br>
</font></td>
</tr>
</table></td>
</tr>
<tr>
<td width="588" align="center"> <form name="form1" method="post" action="adminresult.jsp">
<table width="85%" border="0" cellpadding="3" cellspacing="1" bgcolor="#666666">
<tr>
<td bgcolor="E3EDFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17%"><strong>Userna me:</stron g></td>
<td width="83%"><input name="Username" type="text" id="Username"></td>
</tr>
</table></td>
</tr>
</table>
<table width="85%" border="0" cellpadding="3" cellspacing="1" bgcolor="#666666">
<tr>
<td bgcolor="E3EDFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17%"><strong>Passwo rd:</stron g></td>
<td width="83%"><input name="Password" type="password" id="Password"></td>
</tr>
</table></td>
</tr>
</table>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
<p><br>
</p>
</form>
</td>
<td width="15" align="center" valign="top"> </td>
</tr>
<tr>
<td colspan="2" valign="bottom"><table width="82%" border="0" cellspacing="0" cellpadding="8">
<tr>
<td align="center" valign="bottom"><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif">©
2005 Momentum Marketing Services Ltd.</font></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
adminresult.jsp:
<%@ page import="java.sql.*" %>
<html>
<head>
<title>Admin Verification</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "oracle.jdbc.driver.Oracle Driver";
Class.forName(driverName);
// Create a connection to the database
String serverName = "witnt07.wit.ie";
String portNumber = "1521";
String sid = "orawit";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "W01445693";
String password = "EPEDXZ";
connection = DriverManager.getConnectio n(url, username, password);
} catch (ClassNotFoundException e) {
out.println( "Could not find the database driver");
} catch (SQLException e) {
e.printStackTrace();
out.println( "Could not connect to the database");
}
%>
<%
session.setAttribute("User name",requ est.getPar ameter("Us ername"));
try
{
String user = request.getParameter("User name");
String formPassword = request.getParameter("Pass word");
String Password = null;
Statement stmt = connection.createStatement ();
ResultSet rs = stmt.executeQuery("select Pass from Supervisor WHERE Username = '" + user + "'");
if( formPassword == null) {
String redirectURL = "/momentum/error.jsp";
response.sendRedirect(redi rectURL);
}
else {
if( rs.next() )
{
Password = rs.getString("Password");
if( formPassword.equals( Password ) )
{
//login sucess
String redirectURL = "/momentum/adminoptions.js p";
response.sendRedirect(redi rectURL);
}
else
{
//login failed
String redirectURL = "/momentum/error.jsp";
response.sendRedirect(redi rectURL);
}
}
else
{
//Login failed
String redirectURL = "/momentum/error1.jsp";
response.sendRedirect(redi rectURL);
}
}
}
finally
{
connection.close();
}
%>
</body>
</html>
the error that im getting is as follows:
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
java.lang.NullPointerExcep tion
at org.apache.jsp.adminresult $jsp._jspS ervice(adm inresult$j sp.java:14 4)
at org.apache.jasper.runtime. HttpJspBas e.service( HttpJspBas e.java:107 )
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 853)
at org.apache.jasper.servlet. JspServlet $JspServle tWrapper.s ervice(Jsp Servlet.ja va:201)
at org.apache.jasper.servlet. JspServlet .serviceJs pFile(JspS ervlet.jav a:381)
at org.apache.jasper.servlet. JspServlet .service(J spServlet. java:473)
at javax.servlet.http.HttpSer vlet.servi ce(HttpSer vlet.java: 853)
at org.apache.catalina.core.A pplication FilterChai n.internal DoFilter(A pplication FilterChai n.java:247 )
at org.apache.catalina.core.A pplication FilterChai n.doFilter (Applicati onFilterCh ain.java:1 93)
at org.apache.catalina.core.S tandardWra pperValve. invoke(Sta ndardWrapp erValve.ja va:243)
at org.apache.catalina.core.S tandardPip eline.invo keNext(Sta ndardPipel ine.java:5 66)
at org.apache.catalina.core.S tandardPip eline.invo ke(Standar dPipeline. java:472)
at org.apache.catalina.core.C ontainerBa se.invoke( ContainerB ase.java:9 43)
at org.apache.catalina.core.S tandardCon textValve. invoke(Sta ndardConte xtValve.ja va:190)
at org.apache.catalina.core.S tandardPip eline.invo keNext(Sta ndardPipel ine.java:5 66)
at org.apache.catalina.valves .Certifica tesValve.i nvoke(Cert ificatesVa lve.java:2 46)
at org.apache.catalina.core.S tandardPip eline.invo keNext(Sta ndardPipel ine.java:5 64)
at org.apache.catalina.core.S tandardPip eline.invo ke(Standar dPipeline. java:472)
at org.apache.catalina.core.C ontainerBa se.invoke( ContainerB ase.java:9 43)
at org.apache.catalina.core.S tandardCon text.invok e(Standard Context.ja va:2347)
at org.apache.catalina.core.S tandardHos tValve.inv oke(Standa rdHostValv e.java:180 )
at org.apache.catalina.core.S tandardPip eline.invo keNext(Sta ndardPipel ine.java:5 66)
at org.apache.catalina.valves .ErrorDisp atcherValv e.invoke(E rrorDispat cherValve. java:170)
at org.apache.catalina.core.S tandardPip eline.invo keNext(Sta ndardPipel ine.java:5 64)
at org.apache.catalina.valves .ErrorRepo rtValve.in voke(Error ReportValv e.java:170 )
at org.apache.catalina.core.S tandardPip eline.invo keNext(Sta ndardPipel ine.java:5 64)
at org.apache.catalina.valves .AccessLog Valve.invo ke(AccessL ogValve.ja va:468)
at org.apache.catalina.core.S tandardPip eline.invo keNext(Sta ndardPipel ine.java:5 64)
at org.apache.catalina.core.S tandardPip eline.invo ke(Standar dPipeline. java:472)
at org.apache.catalina.core.C ontainerBa se.invoke( ContainerB ase.java:9 43)
at org.apache.catalina.core.S tandardEng ineValve.i nvoke(Stan dardEngine Valve.java :174)
at org.apache.catalina.core.S tandardPip eline.invo keNext(Sta ndardPipel ine.java:5 66)
at org.apache.catalina.core.S tandardPip eline.invo ke(Standar dPipeline. java:472)
at org.apache.catalina.core.C ontainerBa se.invoke( ContainerB ase.java:9 43)
at org.apache.catalina.connec tor.http.H ttpProcess or.process (HttpProce ssor.java: 1027)
at org.apache.catalina.connec tor.http.H ttpProcess or.run(Htt pProcessor .java:1125 )
at java.lang.Thread.run(Threa d.java:536 )
Sorry about the length of my post. Im not all that familiar with JSP so im not even sure where the error might be coming from!
any ideas??
thanks!
Im attempting to create a login in jsp with the following form and jsp page to process it....
home.jsp:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<br>
<br>
<head>
<title>Momentum Marketing Intranet</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../ROOT/Momentum/tex
<style type="text/css">
<!--
.style1 {font-size: 14px}
.style2 {
font-family: "Times New Roman", Times, serif;
font-size: 16px;
}
-->
</style>
</head>
<body bgcolor="#FFFFFF">
<table width="770" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">
<tr>
<td bgcolor="#FFFFFF"><table width="770" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><a href="../ROOT/Momentum/ind
<td width="411"> </td>
</tr>
<tr>
<td width="359"><img src="../ROOT/Momentum/left
<td align="right" bgcolor="336CA1"> </t
</tr>
<tr>
<td colspan="2"><img src="../ROOT/Momentum/topb
</tr>
<tr>
<td colspan="2">
<table width="100%" border="0" cellspacing="0" cellpadding="0" background="../ROOT/Moment
<tr>
<td align="right"><img src="../ROOT/Momentum/spac
</tr>
</table>
</td>
</tr>
</table>
<table width="770" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="167" rowspan="3" valign="top" bgcolor="8FBEE8"> </td>
<td colspan="2" align="center"><table width="95%" border="0" cellpadding="5" cellspacing="0" class="text">
<tr>
<td class="text"><font color="#000000"><span class="style1"><br>
<span class="style2">Welcome to the Momentum Marketing company Intranet. Please authenticate yourself with our database to access the administration section. </span></span><br>
<br>
</font></td>
</tr>
</table></td>
</tr>
<tr>
<td width="588" align="center"> <form name="form1" method="post" action="adminresult.jsp">
<table width="85%" border="0" cellpadding="3" cellspacing="1" bgcolor="#666666">
<tr>
<td bgcolor="E3EDFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17%"><strong>Userna
<td width="83%"><input name="Username" type="text" id="Username"></td>
</tr>
</table></td>
</tr>
</table>
<table width="85%" border="0" cellpadding="3" cellspacing="1" bgcolor="#666666">
<tr>
<td bgcolor="E3EDFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17%"><strong>Passwo
<td width="83%"><input name="Password" type="password" id="Password"></td>
</tr>
</table></td>
</tr>
</table>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
<p><br>
</p>
</form>
</td>
<td width="15" align="center" valign="top"> </td>
</tr>
<tr>
<td colspan="2" valign="bottom"><table width="82%" border="0" cellspacing="0" cellpadding="8">
<tr>
<td align="center" valign="bottom"><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif">©
2005 Momentum Marketing Services Ltd.</font></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
adminresult.jsp:
<%@ page import="java.sql.*" %>
<html>
<head>
<title>Admin Verification</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "oracle.jdbc.driver.Oracle
Class.forName(driverName);
// Create a connection to the database
String serverName = "witnt07.wit.ie";
String portNumber = "1521";
String sid = "orawit";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "W01445693";
String password = "EPEDXZ";
connection = DriverManager.getConnectio
} catch (ClassNotFoundException e) {
out.println( "Could not find the database driver");
} catch (SQLException e) {
e.printStackTrace();
out.println( "Could not connect to the database");
}
%>
<%
session.setAttribute("User
try
{
String user = request.getParameter("User
String formPassword = request.getParameter("Pass
String Password = null;
Statement stmt = connection.createStatement
ResultSet rs = stmt.executeQuery("select Pass from Supervisor WHERE Username = '" + user + "'");
if( formPassword == null) {
String redirectURL = "/momentum/error.jsp";
response.sendRedirect(redi
}
else {
if( rs.next() )
{
Password = rs.getString("Password");
if( formPassword.equals( Password ) )
{
//login sucess
String redirectURL = "/momentum/adminoptions.js
response.sendRedirect(redi
}
else
{
//login failed
String redirectURL = "/momentum/error.jsp";
response.sendRedirect(redi
}
}
else
{
//Login failed
String redirectURL = "/momentum/error1.jsp";
response.sendRedirect(redi
}
}
}
finally
{
connection.close();
}
%>
</body>
</html>
the error that im getting is as follows:
type Exception report
message Internal Server Error
description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.
exception
java.lang.NullPointerExcep
at org.apache.jsp.adminresult
at org.apache.jasper.runtime.
at javax.servlet.http.HttpSer
at org.apache.jasper.servlet.
at org.apache.jasper.servlet.
at org.apache.jasper.servlet.
at javax.servlet.http.HttpSer
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.C
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.C
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.C
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.C
at org.apache.catalina.connec
at org.apache.catalina.connec
at java.lang.Thread.run(Threa
Sorry about the length of my post. Im not all that familiar with JSP so im not even sure where the error might be coming from!
any ideas??
thanks!
Hi,
Moreover, Password = rs.getString("Password");
is not correct.
this should be Password = rs.getString("Pass");
OR use SELECT Pass AS Password FROM....
in the query to make the present jsp work.
fargo
Moreover, Password = rs.getString("Password");
is not correct.
this should be Password = rs.getString("Pass");
OR use SELECT Pass AS Password FROM....
in the query to make the present jsp work.
fargo
ASKER
connection.close();
is at line 144..... would this be a problem?
is at line 144..... would this be a problem?
This would indicate that the connection object is null and that you never create a connection
Also, you have a try statement with no catch only a finally
try
{
String user = request.getParameter
("Username");
...//where is the catch block after this?
This maybe why it is not working
Also, you have a try statement with no catch only a finally
try
{
String user = request.getParameter
("Username");
...//where is the catch block after this?
This maybe why it is not working
Hi,
did you check in the work directory???
Moreover, if connection.close() is at line 144. It means, at first step u are not able to get the connection.
Please put some logging information in-between to check whether u are able to get the connection or not??
fargo
did you check in the work directory???
Moreover, if connection.close() is at line 144. It means, at first step u are not able to get the connection.
Please put some logging information in-between to check whether u are able to get the connection or not??
fargo
good catch...bloodredsun.
fargo
fargo
ASKER
sorry, ive just checked my original code and im missing this at the end:
}
// end
// HTML // begin [file="/adminresult.jsp";f rom=(94,2) ;to=(98,0) ]
out.write("\r\n \r\n</body>\r\n</html>\r\n ");
// end
} catch (Throwable t) {
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (pageContext != null) pageContext.handlePageExce ption(t);
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageCo ntext(page Context);
}
}
}
I forgot to put that in the original post, aplogies!
}
// end
// HTML // begin [file="/adminresult.jsp";f
out.write("\r\n \r\n</body>\r\n</html>\r\n
// end
} catch (Throwable t) {
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (pageContext != null) pageContext.handlePageExce
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageCo
}
}
}
I forgot to put that in the original post, aplogies!
well, the code you posted just now is from the generated java file.
fargo
fargo
very droll fargo :-)
ASKER
sorry about that,
OK code now is:
<%@ page import="java.sql.*" %>
<html>
<head>
<title>Admin Verification</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "oracle.jdbc.OracleDriver" ;
Class.forName(driverName);
// Create a connection to the database
String serverName = "witnt07.wit.ie";
String portNumber = "1521";
String sid = "orawit";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "W01445693";
String password = "EPDEXZ";
connection = DriverManager.getConnectio n(url, username, password);
} catch (ClassNotFoundException e) {
out.println( "Could not find the database driver");
} catch (SQLException e) {
e.printStackTrace();
out.println( "Could not connect to the database");
}
%>
<%
session.setAttribute("User name",requ est.getPar ameter("Us ername"));
try
{
String user = request.getParameter("User name");
String formPassword = request.getParameter("Pass word");
String Password = null;
Statement stmt = connection.createStatement ();
ResultSet rs = stmt.executeQuery("select Pass from Supervisor WHERE Username = '" + user + "'");
if( formPassword == null) {
String redirectURL = "/momentum/error.jsp";
response.sendRedirect(redi rectURL);
}
else {
if( rs.next() )
{
Password = rs.getString("Pass");
if( formPassword.equals( Password ) )
{
//login sucess
String redirectURL = "/momentum/adminoptions.js p";
response.sendRedirect(redi rectURL);
}
else
{
//login failed
String redirectURL = "/momentum/error.jsp";
response.sendRedirect(redi rectURL);
}
}
else
{
//Login failed
String redirectURL = "/momentum/error1.jsp";
response.sendRedirect(redi rectURL);
}
}
}
finally
{
connection.close();
}
%>
</body>
</html>
works other than the fact that its redirecting to error.jsp despite the fact that the correct details are being entered and the tables in the db are correct.
OK code now is:
<%@ page import="java.sql.*" %>
<html>
<head>
<title>Admin Verification</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "oracle.jdbc.OracleDriver"
Class.forName(driverName);
// Create a connection to the database
String serverName = "witnt07.wit.ie";
String portNumber = "1521";
String sid = "orawit";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "W01445693";
String password = "EPDEXZ";
connection = DriverManager.getConnectio
} catch (ClassNotFoundException e) {
out.println( "Could not find the database driver");
} catch (SQLException e) {
e.printStackTrace();
out.println( "Could not connect to the database");
}
%>
<%
session.setAttribute("User
try
{
String user = request.getParameter("User
String formPassword = request.getParameter("Pass
String Password = null;
Statement stmt = connection.createStatement
ResultSet rs = stmt.executeQuery("select Pass from Supervisor WHERE Username = '" + user + "'");
if( formPassword == null) {
String redirectURL = "/momentum/error.jsp";
response.sendRedirect(redi
}
else {
if( rs.next() )
{
Password = rs.getString("Pass");
if( formPassword.equals( Password ) )
{
//login sucess
String redirectURL = "/momentum/adminoptions.js
response.sendRedirect(redi
}
else
{
//login failed
String redirectURL = "/momentum/error.jsp";
response.sendRedirect(redi
}
}
else
{
//Login failed
String redirectURL = "/momentum/error1.jsp";
response.sendRedirect(redi
}
}
}
finally
{
connection.close();
}
%>
</body>
</html>
works other than the fact that its redirecting to error.jsp despite the fact that the correct details are being entered and the tables in the db are correct.
catch block is again missing.
fargo
fargo
ASKER
ah i see....
How would i go about coding that catch in?
How would i go about coding that catch in?
} catch(Exception ex){
System.out.println("Except ion", ex);
}finally
{
connection.close();
}
fargo
System.out.println("Except
}finally
{
connection.close();
}
fargo
ASKER
getting this error now:
An error occurred between lines: 37 and 97 in the jsp file: /adminresult.jsp
Generated servlet error:
D:\tomcat4\work\Standalone \localhost \_\adminre sult$jsp.j ava:139: 'catch' without 'try'.
} catch(Exception ex){
An error occurred between lines: 37 and 97 in the jsp file: /adminresult.jsp
Generated servlet error:
D:\tomcat4\work\Standalone
} catch(Exception ex){
The last section should be this
try
{
String user = request.getParameter("User name");
String formPassword = request.getParameter("Pass word");
String Password = null;
Statement stmt = connection.createStatement ();
ResultSet rs = stmt.executeQuery("select Pass from Supervisor WHERE Username = '" + user + "'");
if( formPassword == null) {
String redirectURL = "/momentum/error.jsp";
response.sendRedirect(redi rectURL);
}
else {
if( rs.next() )
{
Password = rs.getString("Pass");
if( formPassword.equals( Password ) )
{
//login sucess
String redirectURL = "/momentum/adminoptions.js p";
response.sendRedirect(redi rectURL);
}
else
{
//login failed
String redirectURL = "/momentum/error.jsp";
response.sendRedirect(redi rectURL);
}
}
else
{
//Login failed
String redirectURL = "/momentum/error1.jsp";
response.sendRedirect(redi rectURL);
}
}
}catch(Exception ex){
System.out.println("Except ion", ex);
}finally
{
connection.close();
}
fargo
try
{
String user = request.getParameter("User
String formPassword = request.getParameter("Pass
String Password = null;
Statement stmt = connection.createStatement
ResultSet rs = stmt.executeQuery("select Pass from Supervisor WHERE Username = '" + user + "'");
if( formPassword == null) {
String redirectURL = "/momentum/error.jsp";
response.sendRedirect(redi
}
else {
if( rs.next() )
{
Password = rs.getString("Pass");
if( formPassword.equals( Password ) )
{
//login sucess
String redirectURL = "/momentum/adminoptions.js
response.sendRedirect(redi
}
else
{
//login failed
String redirectURL = "/momentum/error.jsp";
response.sendRedirect(redi
}
}
else
{
//Login failed
String redirectURL = "/momentum/error1.jsp";
response.sendRedirect(redi
}
}
}catch(Exception ex){
System.out.println("Except
}finally
{
connection.close();
}
fargo
ASKER
still getting this error:
org.apache.jasper.JasperEx ception: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
An error occurred between lines: 37 and 96 in the jsp file: /adminresult.jsp
Generated servlet error:
D:\tomcat4\work\Standalone \localhost \_\adminre sult$jsp.j ava:141: Wrong number of arguments in method.
System.out.println("Except ion", ex);
org.apache.jasper.JasperEx
An error occurred between lines: 37 and 96 in the jsp file: /adminresult.jsp
Generated servlet error:
D:\tomcat4\work\Standalone
System.out.println("Except
Sorry. The exception should be like
System.out.println(ex.getM essage());
fargo
System.out.println(ex.getM
fargo
You seem to have this in hand fargo so I'll unsub now :-)
bloodredsun, if you are around...my points are always in danger... -:)
Anyway, this should be your question. You catch the catch.
fargo
Anyway, this should be your question. You catch the catch.
fargo
ha! These are your points, you worked for them and I have more than enough :-)
In fact I'm looking forward to see who will become the next featured expert (highest scorer of the last month - on the left hand nav) between you, radarsh and TimYates as it won't be me anymore.
In fact I'm looking forward to see who will become the next featured expert (highest scorer of the last month - on the left hand nav) between you, radarsh and TimYates as it won't be me anymore.
hi bloodredsun. Thanks for encouraging words. BTW, radarsh and Tim are oldies...and they are the real experts. I am just started to hang around more. You cannot be touched.....
fargo
fargo
Won't be me ;-) I can't get a look in here or in Java these days ;-)
My poor old hands just aren't quick enough ;-)
heheheh
My poor old hands just aren't quick enough ;-)
heheheh
old hands! Watch it mate I'm older than you so what does that say about me! ;-)
hehehe soz granddad ;-)
*runs off to bed and pretends to be asleep* ;-D
See y'all tomorrow :-)
*runs off to bed and pretends to be asleep* ;-D
See y'all tomorrow :-)
Are you using JRE 1.5 ??? and more on which servlet engine are you using (tomact) or web server are you using???
and 1st please try this & then get back.
change the catch block as follows.
catch(Exception ex){
ex.printStackTrace();
}
and 1st please try this & then get back.
change the catch block as follows.
catch(Exception ex){
ex.printStackTrace();
}
ASKER
fargo,
im still getting the same error im afraid. the page isnt logging in despite the fact that the code is correct
shivaspk, ive tried yours and i get the following error:
org.apache.jasper.JasperEx ception: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
D:\tomcat4\work\Standalone \localhost \_\adminre sult$jsp.j ava:155: Type expected.
} catch (Throwable t) {
^
1 error, 1 warning
im still getting the same error im afraid. the page isnt logging in despite the fact that the code is correct
shivaspk, ive tried yours and i get the following error:
org.apache.jasper.JasperEx
D:\tomcat4\work\Standalone
} catch (Throwable t) {
^
1 error, 1 warning
Can you check the value for the following in the adminresult.jsp page
String user = request.getParameter("User name");
String formPassword = request.getParameter("Pass word");
String Password = rs.getString("Pass");
post the values for the above three values.
regards,
fargo
String user = request.getParameter("User
String formPassword = request.getParameter("Pass
String Password = rs.getString("Pass");
post the values for the above three values.
regards,
fargo
ASKER
try
{
String user = request.getParameter("User name");
String formPassword = request.getParameter("Pass word");
String Password = null;
Statement stmt = connection.createStatement ();
ResultSet rs = stmt.executeQuery("select Pass from Supervisor WHERE Username = '" + user + "'");
if( formPassword == null) {
String redirectURL "/momentum/error.jsp";
response.sendRedirect(redi rectURL);
}
else {
if( rs.next() )
{
Password = rs.getString("Password");
if( formPassword.equals( Password ) )
{
//login sucess
String redirectURL = "/momentum/adminoptions.js p";
response.sendRedirect(redi rectURL);
{
String user = request.getParameter("User
String formPassword = request.getParameter("Pass
String Password = null;
Statement stmt = connection.createStatement
ResultSet rs = stmt.executeQuery("select Pass from Supervisor WHERE Username = '" + user + "'");
if( formPassword == null) {
String redirectURL "/momentum/error.jsp";
response.sendRedirect(redi
}
else {
if( rs.next() )
{
Password = rs.getString("Password");
if( formPassword.equals( Password ) )
{
//login sucess
String redirectURL = "/momentum/adminoptions.js
response.sendRedirect(redi
what is it that you posted??
fargo
fargo
ASKER
sorry ive misunderstood what you asked there, i thought you meant to post the values carrying into the java file.
what exactly do you mean?
what exactly do you mean?
I mean the following
String user = request.getParameter("User name");
System.out.println("User is "+user);
String formPassword = request.getParameter("Pass word");
System.out.println("formPa ssword is "+formPassword);
String Password = rs.getString("Pass");
System.out.println("Passwo rd is "+Password);
We can then expect the results.
fargo
String user = request.getParameter("User
System.out.println("User is "+user);
String formPassword = request.getParameter("Pass
System.out.println("formPa
String Password = rs.getString("Pass");
System.out.println("Passwo
We can then expect the results.
fargo
ASKER
where abouts do i place this code beacuse ive tried it like this below and no luck:
String user = request.getParameter("User name");
System.out.println("User is "+user);
String formPassword = request.getParameter("Pass word");
System.out.println("formPa ssword is "+formPassword);
String Password = null;
Statement stmt = connection.createStatement ();
ResultSet rs = stmt.executeQuery("select Pass from Supervisor WHERE Username = '" + user + "'");
if( formPassword == null) {
String redirectURL = "error.jsp";
response.sendRedirect(redi rectURL);
}
else {
if( rs.next() )
{
Password = rs.getString("Pass");
System.out.println("Passwo rd is "+Password);
all it does is spit back the error1.jsp page to me.
String user = request.getParameter("User
System.out.println("User is "+user);
String formPassword = request.getParameter("Pass
System.out.println("formPa
String Password = null;
Statement stmt = connection.createStatement
ResultSet rs = stmt.executeQuery("select Pass from Supervisor WHERE Username = '" + user + "'");
if( formPassword == null) {
String redirectURL = "error.jsp";
response.sendRedirect(redi
}
else {
if( rs.next() )
{
Password = rs.getString("Pass");
System.out.println("Passwo
all it does is spit back the error1.jsp page to me.
Hi,
If it is going to error1.jsp..it means the formPassword is null. You can check the output in console for the above we did.
are you using logging like log4j etc.?
fargo
If it is going to error1.jsp..it means the formPassword is null. You can check the output in console for the above we did.
are you using logging like log4j etc.?
fargo
ASKER
no im not using any logging... im very new to java as you can see ;-)
Perhaps my form is the problem?
<form name="form1" method="post" action="adminresult.jsp">
<table width="85%" border="0" cellpadding="3" cellspacing="1" bgcolor="#666666">
<tr>
<td bgcolor="E3EDFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17%"><strong>Userna me:</stron g></td>
<td width="83%"><input name="Username" type="text" id="Username"></td>
</tr>
</table></td>
</tr>
</table>
<table width="85%" border="0" cellpadding="3" cellspacing="1" bgcolor="#666666">
<tr>
<td bgcolor="E3EDFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17%"><strong>Passwo rd:</stron g></td>
<td width="83%"><input name="Password" type="password" id="Password"></td>
</tr>
</table></td>
</tr>
</table>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
<p><br>
</p>
</form>
Perhaps my form is the problem?
<form name="form1" method="post" action="adminresult.jsp">
<table width="85%" border="0" cellpadding="3" cellspacing="1" bgcolor="#666666">
<tr>
<td bgcolor="E3EDFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17%"><strong>Userna
<td width="83%"><input name="Username" type="text" id="Username"></td>
</tr>
</table></td>
</tr>
</table>
<table width="85%" border="0" cellpadding="3" cellspacing="1" bgcolor="#666666">
<tr>
<td bgcolor="E3EDFF"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="17%"><strong>Passwo
<td width="83%"><input name="Password" type="password" id="Password"></td>
</tr>
</table></td>
</tr>
</table>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
<p><br>
</p>
</form>
Hi,
form seems to be fine.
>> You can check the output in console for the above we did
have u checked this???
You definitely has to check what values you are getting from the form and against what you are checking.
fargo
form seems to be fine.
>> You can check the output in console for the above we did
have u checked this???
You definitely has to check what values you are getting from the form and against what you are checking.
fargo
ASKER
How do you mean in console?
ASKER
I have it, one moment.
ASKER
ASKER
good. What is coming with the resultset then?
rs.getString("Pass");
fargo
rs.getString("Pass");
fargo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please go to the work directory of tomcat.
tomcat-path/work/org/apach
and check the line 144.
There is some variable which is getting null.
Let us know if you have problem understanding the line 144 in the java file.
regards,
fargo