Dean_Grobler 48 Posting Whiz in Training

Hello there,

I am trying to access Array elements in another class within my JSP and then parsing them into <select> tags. I'm getting 2 errors though stating that it cannot find the class "PopulateMainScr".

Here is my PopulateMainScr class:

package ContactKeeper;

import java.io.*;
import java.sql.*;
import java.util.*;

public class PopulateMainScr {

	public static String[] getArray(){

		//DataBase Properties
		String JDBCdriver = "sun.jdbc.odbc.JdbcOdbcDriver";
		String DBname = "ContactDataBase";
		String DBUrl = "jdbc:odbc:ContactDataBase";
		ArrayList al = new ArrayList();

		try{
			//Load DataBase Driver
			Class.forName(JDBCdriver);
		}
		catch(ClassNotFoundException c){
			System.out.println("An error Occured while loading DataBase Driver: "+c.getMessage());
		}

		try{
			//Connect to DataBase
			Connection con = DriverManager.getConnection(DBUrl);

			//Create Statement Object
			Statement stmt = con.createStatement();

			//Create ResultSet
			ResultSet rs = stmt.executeQuery("SELECT * FROM Contacts");

			//SQL Queries and adding to ArrayList
			try{
				while(rs.next()){

					String combo = (rs.getString("Name")+" "+rs.getString("Surname"));
					System.out.println(combo);
					al.add(combo);
				}
			}
			catch(SQLException q){
				System.out.println("A SQL exception occured while trying to read data from database: "+q.getMessage());
			}

		}
		catch(SQLException s){
			System.out.println("And SQL Exception occured: "+s.getMessage());
		}

		//Convert ArrayList to Array
		int arrayListSize = al.size();
		String []contactArray = new String[arrayListSize];
		al.toArray(contactArray);

		return contactArray;

	}

}

And here is my JSP Page:

<!-- the NewContact Screen -->
<html>
<head>
<link rel="stylesheet" type="text/css" href="PageStyle.css" />
<title>MainScreen</title>
</head>

<script language"JavaScript">
<!--
function goNewContact() {
	//URL for button to follow
	window.location="http://localhost:8080/ContactKeeper/newContactScreen.html";
}

function goViewContact() {
	//URL for button to follow
	window.location="http://localhost:8080/ContactKeeper/viewContactScreen.html";
}

-->
</script>

<body>




<center>
<img src="Images/Header.png">

<form>

	<input type="button" value="Search"/>
	<input type="text" name="Search Query" />

</form>

<form>
	<!-- Contact List on the MainScreen -->
	<select style="width: 210px; height: 200px" name="contactName" multiple>
	<% 
	String[] myArray = ContactKeeper.PopulateMainScr.getArray(); 
	for(int i =0; i < myArray.length(); ++i){
	%>
	
	<option value="<%= myArray[i] %>" >
	<%= myArray[i] %>
	</option>
	<%
	}
	%>
	</select></br></br>

	<td><input type="button" value="View Contact" onclick="goViewContact()" >
	<td><input type="button" value="Delete Contact"/></br>

	<td><input type="button" value="New Contact" onclick="goNewContact()" >

</form>

</center>

</body>
</html>

I don't know if this has anything to do with import statements, although the tutorials I've read that does something similiar to this doesn't make use of import statements at all. Also I don't know if this might have something to do with my CLASSPATH?

I'm using Tomcat so the the actual JSP page is located under ROOT\ContactKeeper/ and my PopulateMainScr class is located under ROOT\WEB-INF\classes\

Thanks for any help!