File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Help for a  simple jSP program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Help for a  simple jSP program" Watch "Help for a  simple jSP program" New topic

Help for a simple jSP program

Jaya Nettem

Joined: May 10, 2005
Posts: 24

I am trying to a very simple JSP program and it is not working.
Here is the listing:

Basic Counter: Page Count is:

package foo;

public class Counter {

private static int count;
public static int getCount()
return count;

I have compiled and placed it in webapps/MyApp/WEB-INF/classes/foo

When I try to bring up JSP page, I get the error saying that
"class Counter not found".

I even tried removing the package statement from and compiled it and placed it in appropriate place. It still fails. Am I missing some path variables .. or something of that sort ?
By the way I am using Tomcat 4.1 for testing.


I have wasted a lot of time on this.

Thanks in advance.

sergio mendez-rueda
Ranch Hand

Joined: May 12, 2005
Posts: 37
hi nettem,

1.- place your BasicCounter.jsp in:
2.- start tomcat
3.- call in your browser:
(8080 is the default port of tomcat;-)
the file and directory structure os your web app must be somethink like that:

enjoy tomcat (why are you using tomcat version 4.1??)
Sanjay pts
Ranch Hand

Joined: Nov 07, 2000
Posts: 357
I think you have to import class using
<%@ page import="foo.Counter" %>


Eat JAVA, Drink JAVA, Sleep Java
Jaya Nettem

Joined: May 10, 2005
Posts: 24
Thanks for your replies.

I tried both approaches (importing/and specifying complete path ... of course separately ...) and the rest needed (I am following HF Series for Servlets and JSPs) .. I still get the same error ... I even tried not specifying the package at all ... so that I do not have to import and the class could go straight into WEB-INF/classes directory ... still Counter class is not recognised) ... I tested the JSP without using the Counter class .. it works fine (so I know that web.xml is correct) ...
seemapanth Joshi
Ranch Hand

Joined: Nov 28, 2004
Posts: 47
tried both approaches (importing/and specifying complete path ... of course separately ...)

Using both together should not give you any problems either.

(so I know that web.xml is correct) ...

I don't think you need anything in web.xml for this to run.

I would suggest looking at your Tomcat log files located at tomcat-home\logs. Could there be a relation between what it is reading from the DD and the locating of the counter class. By the way I copied your scenario and it works perfectly for me, so it could be something else.
I agree. Here's the link:
subject: Help for a simple jSP program
It's not a secret anymore!