Internal server error: cant find whats wrong!

Im attempting to create a login system for an admin locally on my pc. the database being used is oracle8 and im making use of apache tomcat. admin uname and password are stored in the fields of the db called 'username' and 'pass'. the code for the form and adminresult.jsp are as follows:

<!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="text.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=" index.jsp"><img src="mom_logo.gif" width="256" height="74" border="0"></a></td>
          <td width="411">&nbsp;</td>
        </tr>
        <tr>
          <td width="359"><img src="leftbar.gif" width="359" height="39"></td>
          <td align="right" bgcolor="336CA1">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="2"><img src="topbar.gif" width="770" height="69"></td>
        </tr>
        <tr>
          <td colspan="2">
            <table width="100%" border="0" cellspacing="0" cellpadding="0" background="but_bg.gif">
              <tr>
                <td align="right"><img src="spacer.gif" width="15" height="23"><img src="spacer.gif" width="15" height="23"><img src=" spacer.gif" width="15" height="23"><img src="spacer.gif" width="15" height="23"><img src="spacer.gif" width="15" height="23"><img src=" spacer.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">&nbsp;          </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>Username:</strong></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>Password:</strong></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">&nbsp; </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">&copy;
                  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.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 = "username";
        String password = "password";
        connection = DriverManager.getConnection(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("Username",request.getParameter("Username"));

try
{
    String user = request.getParameter("Username");
    String formPassword = request.getParameter("Password");
 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(redirectURL);
 }
 else {
  if( rs.next() )
  {
   Password = rs.getString("Password");
       
   if( formPassword.equals( Password ) )
   {
    //login sucess
   
  String redirectURL = "/momentum/adminoptions.jsp";
        response.sendRedirect(redirectURL);


   
   }
   else
   {
    //login failed
   
  String redirectURL = "/momentum/error.jsp";
        response.sendRedirect(redirectURL);
 
   }
   
  }
  else
  {
   //Login failed
  String redirectURL = "/momentum/error1.jsp";
        response.sendRedirect(redirectURL);
  }
 }
 }
 
finally
{
    connection.close();
}

%>
 
</body>
</html>

the error being produced is:

Apache Tomcat/4.0.4 - HTTP Status 500 - Internal Server Error


any ideas what may but wrong here?

LVL 2
clonmelogAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
fargoCommented:
Hi,

in the following code...

 else {
  if( rs.next() )
  {
   Password = rs.getString("Password");  // THIS IS NOT CORRECT

should be
Password = rs.getString("Pass");

fargo

0
 
clonmelogAuthor Commented:
sorry that was a mod i made while playing around.

Ive tried this code to check my connection and it seems to fail:

<%@ page language="java" import="java.sql.*" contentType="text/html;charset=windows-1252"%>

<HTML>

<HEAD>

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1252">

<TITLE>

Hello World

</TITLE>

</HEAD>

<BODY>

<H2>

The current time is:

</H2>

<P>

<% // Call built-in Date Method

 out.println((new java.util.Date()).toString()); %>

</P>



<% Connection con = null;



    try {

      out.println("Connecting to Server.... ");



      // Load the Driver class file

      DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());



      // Make a connection to the datasource

      con = DriverManager.getConnection("jdbc:oracle:thin:@witnt07.wit.ie:1521:orawit",

"username", "password");



      // Create the statement

      Statement statement = con.createStatement();



      // Use the created statement to SELECT the DATA FROM the Emp Table.

      ResultSet rs = statement.executeQuery("select * from scott.emp");



      // Iterate over the ResultSet

      %>



      <!-- Add an HTML table to format the results -->

      <table border = 1>

      <%

      while ( rs.next() ) {



        // get the 1st Field

        out.println("<tr><td> " + rs.getString(1) + "</td> ");



        // get the 2nd Field

        out.println(" <td>" + rs.getString(2) + "</td> ");



        // get the 3rd Field

        out.println("<td> " + rs.getString(3) + "</td> ");



        // get the 4th Field

        out.println("<td> " + rs.getString(4) + "</td></tr> ");

      }

      // Close the ResultSet

      rs.close();

    }



    catch (IOException ioe) {



      out.println(ioe.getMessage());

    }

    catch (SQLException sqle) {



      out.println(sqle.getMessage());

    }

//    catch (ClassNotFoundException cnfe) {



//      out.println(cnfe.getMessage());

//    }

    catch (Exception e) {



      out.println(e.getMessage());

    }

    finally {



      try {

        if ( con != null ) {

          // Close the connection no matter what

          con.close();

        }

      }

      catch (SQLException sqle) {

out.println(sqle.getMessage());

      }

    }

%>

</table></BODY></HTML>

0
 
fargoCommented:
Hi,

>> DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver()); // this should be removed

should use

....
// Load the JDBC driver
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);
// Make a connection to the datasource
con = DriverManager.getConnection("jdbc:oracle:thin:@witnt07.wit.ie:1521:orawit","username", "password");
...

fargo
0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
 
TimYatesCommented:
Off topic, but I'd close your ResultSet AND Statement in the finally block as well...
0
 
clonmelogAuthor Commented:
well they are internal passwords so they arent really accessible but it may be better to remove them yes please! :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.