Using JavaBeans into JSP
I have a simple example for using Beans in JSP and the problem is that i get this error: org.apache.jasper.JasperException: /BeanCounter.jsp(8,0) The value for the useBean class attribute Counter is invalid.
The program's ideea is to count how many times i've accesed the bean
This is the code: (i'm using Apache Tomcat 5.5)
My bean (Counter):
import java.io.Serializable;
public class Counter implements Serializable{
int count = 0;
public Counter() {
}
public int getCount() {
count++;
return this.count;
}
public void setCount(int count) {
this.count = count;
}
and the code for BeanCounter.jsp :
<HTML>
<HEAD>
<TITLE>JSP Bean Example</TITLE>
</HEAD>
<BODY>
<%@ page language="java" %>
<jsp:useBean id="counter" scope="session" class="Counter" /> //i guess that here is the problem but i don't have a package or anything else
<jsp:setProperty name="counter" property="count" param="count" />
<%
out.println("Count from scriptlet code : "
+ counter.getCount() + "<BR>");
%>
<!-- Get the bean's count property, -->
<!-- using the jsp:getProperty action. -->
Count from jsp:getProperty :
<jsp:getProperty name="counter" property="count" />
</BODY>
</HTML>
The Counter.class is in WEB-INF/classes
I just cannot understand why it doesn't work.Please help :) Thanks in advance

