The JSP doesn’t recognize the Counter class

The Counter class is in the foo package, but there’s nothing in the JSP to acknowledge that. It’s the same thing that happens to you with any other Java code, and you know the rule: import the package or use the fully-qualified class name in your code.

image with no caption

Counter.java

package foo;

public class Counter {
   private static int count;
   public static int getCount() {
       count++;
       return count;
   }
}

JSP code was:

<% out.println(Counter.getCount()); %>

JSP code should be:

image with no caption
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset