views:

2191

answers:

3

can some-one please walk me threw the procces of loading a class or package in jsp with tomcat?

i think it might just be a tomcat setup issue :S my jsp file runs fine without importing or using dbpool or dbpooljar. ive tried many suggestions to other peoples similar issues without any luck. any help would be apreciated!

//============my class/package placed in web-inf/classes (among other places)

package dbpooljar;

public class DBPool {

public DBPool() { System.out.println("dbpool evidence!"); } }

//================my compile commands

javac "C:\website\apache-tomcat-6.0.18\webapps\ROOT\WEB-INF\classes\dbpool.java" jar cf "C:\website\apache-tomcat-6.0.18\webapps\ROOT\WEB-INF\classes\dbpooljar.jar" DBPool.java

//============my index.jsp (i have substiuated tags with [] for displaying)

[%@ page import="java.sql.*,java.util.List,java.util.ArrayList,DBPool" %]

[html] [body] Getting Length of a String <% String s1 = "Length of a String!"; out.println("\"" + s1 + "\"" + " is of " + s1.length() + " characters "); DBPool test=new DBPool(); %> [/body] [/html]

//=============and lastly my horrible error (among others when ive tried differant things

An error occurred at line: 9 in the generated java file The import DBPool cannot be resolved

+1  A: 

You've typed

[%@ page import="java.sql.*,java.util.List,java.util.ArrayList,DBPool" %]

but

package dbpooljar;
public class DBPool { ...

Therefor, it should be

[%@ page import="java.sql.*,java.util.List,java.util.ArrayList,dbpooljar.DBPool" %]

plus your java file should be located in a directory named WEB-INF/classes/dbpooljar or if you insist on packaging a jar file, place the jar file in WEB-INF/lib

Of course the angled brackets "[" and "]" are meant to be proper xml brackets "<" and ">" - I've preserved them here in order to be able to use bold typeface.

Olaf
A: 

as simple as that, that did it, thanx Olaf, its been haunting me for weeks! :D

A: 

I dont know about windows, but in linux there is a the file(/usr/share/tomcat5/conf/jkconfig.manifest) that you can edit to add specific jars to the tomcat instance that is running.

Milhous