I have written some java code that can download some table data from an sql server. It works fine when it is loaded as just a java project and consists of 4 classes: Server.java, Publication.java, Volume.java, SQLPublicationMapper.java. (The third isn't used.)
I am trying to use these custom classes in a jsp project. I have gotten the jsp project to work with tomcat and it works in the browser, but I can't find a way to make it use my custom classes. Where are they supposed to be located? Do they need to be imported?
I have tried placing the class files in: src/jsp, WebContent, WebContent\src. None of these appear to work.
I have spent multiple hours being stuck on this issue and searching but didn't find anything applicable, so I come here.
The index.jsp file is:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Dynamisk jsp side</title>
</head>
<body>
<h1>En test af java til at starte med</h1>
Klokken er (eller var sidste gang du trykkede): <%= new java.util.Date() %><br>
Jeg tæller til 20: <br> <%
int x = 1;
while( x <= 20 ) {
%>
<p>X er lig <%= x %></p>
<% x++;
} %>
<h1>Jeg outputter også hele databasen:</h1>
<%@ page import="dk.au.hum.imv.persistence.db.*,
java.sql.*,
java.util.ArrayList,
com.googlecode.totallylazy.numbers.Numbers.*"
%>
<%
//fetch all publications
System.out.println("All publications");
ArrayList<Publication> publications = SQLPublicationMapper.getAllPublications();
System.out.println("First 5 publications are:");
for (Number idx : range(1,5)) {
System.out.println(publications.get((int) idx).title+" by "+publications.get((int) idx).author);
}
System.out.println("Out of a total of "+publications.size());
%>
</body>
</html>
Eclipse EE gives the following errors: line 32: Publication cannot be resolved to a type Multiple annotations found at this line: - SQLPublicationMapper cannot be resolved - SQLPublicationMapper cannot be resolved line 34: The method range(int, int) is undefined for the type __2F_jsp_2F_WebContent_2F_index_2E_jsp
As far as I can tell, the first error is due to Publication.class not being available. The second the same for SQLPublicationMapper (twice?). The third because of some error importing the functional java (totallyLazy) library. This error does not occur when I just run the java itself.
The appropriate jar files are included in the buildPath settings.
Any ideas?