Problem Tomcat 5 with external java class

A

as314

Hello,

the following example worked fine with Tomcat 4.0.4 but I encounter
problems using Tomcat 5.0.19:

"Dirkie.jsp" in TOMCAT_HOME\webapps\ROOT:
----------------------------
<%@ page language="java" contentType="text/html" %>
<%@ page import="Dirkie" %>
<html>
<head><title>Use external Java class</title></head>
<body>
Test<br><br>
<% Dirkie d = new Dirkie();
out.println(d.getMessage()); %>
</body>
</html>
----------------------------
"Dirkie.class" in TOMCAT_HOME\webapps\ROOT\WEB-INF\classes:
----------------------------
public class Dirkie {
public String getMessage() {
return "Hello Dirkie!";
}
}
----------------------------

When calling "http://localhost:8080/Dirkie.jsp" I get the following
error messages:
----------------------------
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
[javac] Compiling 1 source file

C:\java\tomcat\work\Catalina\localhost\_\org\apache\jsp\Dirkie_jsp.java:6:
'.' expected
import Dirkie;
^
----------------------------

What is the problem?

I hope, this is the right group for such problems.
Please send eMail to "(e-mail address removed)" if possible.

Thanks for your help!

Regards, Alfred
 
C

Christophe Vanfleteren

as314 said:
Hello,

the following example worked fine with Tomcat 4.0.4 but I encounter
problems using Tomcat 5.0.19:

"Dirkie.jsp" in TOMCAT_HOME\webapps\ROOT:
----------------------------
<%@ page language="java" contentType="text/html" %>
<%@ page import="Dirkie" %>
<html>
<head><title>Use external Java class</title></head>
<body>
Test<br><br>
<% Dirkie d = new Dirkie();
out.println(d.getMessage()); %>
</body>
</html>
----------------------------
"Dirkie.class" in TOMCAT_HOME\webapps\ROOT\WEB-INF\classes:
----------------------------
public class Dirkie {
public String getMessage() {
return "Hello Dirkie!";
}
}
----------------------------

When calling "http://localhost:8080/Dirkie.jsp" I get the following
error messages:
----------------------------
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
[javac] Compiling 1 source file

C:\java\tomcat\work\Catalina\localhost\_\org\apache\jsp\Dirkie_jsp.java:6:
'.' expected
import Dirkie;
^

Put Dirkie in a proper package, that should solve the problems.
I hope, this is the right group for such problems.
Please send eMail to "(e-mail address removed)" if possible.

If you post to a newsgroup, expect to read answers in the newsgroup. Don't
ask for responses by email.
 
A

as314

Hello Christophe,

thank you very much. That's it!

Kind regards, Alfred

Christophe Vanfleteren said:
as314 said:
Hello,

the following example worked fine with Tomcat 4.0.4 but I encounter
problems using Tomcat 5.0.19:

"Dirkie.jsp" in TOMCAT_HOME\webapps\ROOT:
----------------------------
<%@ page language="java" contentType="text/html" %>
<%@ page import="Dirkie" %>
<html>
<head><title>Use external Java class</title></head>
<body>
Test<br><br>
<% Dirkie d = new Dirkie();
out.println(d.getMessage()); %>
</body>
</html>
----------------------------
"Dirkie.class" in TOMCAT_HOME\webapps\ROOT\WEB-INF\classes:
----------------------------
public class Dirkie {
public String getMessage() {
return "Hello Dirkie!";
}
}
----------------------------

When calling "http://localhost:8080/Dirkie.jsp" I get the following
error messages:
----------------------------
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
[javac] Compiling 1 source file

C:\java\tomcat\work\Catalina\localhost\_\org\apache\jsp\Dirkie_jsp.java:6:
'.' expected
import Dirkie;
^

Put Dirkie in a proper package, that should solve the problems.
I hope, this is the right group for such problems.
Please send eMail to "(e-mail address removed)" if possible.

If you post to a newsgroup, expect to read answers in the newsgroup. Don't
ask for responses by email.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top