File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Jsp not accessing bean class ! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Jsp not accessing bean class !" Watch "Jsp not accessing bean class !" New topic

Jsp not accessing bean class !

Ghazala Islam
Ranch Hand

Joined: Nov 22, 2000
Posts: 73
I 'm having error running jsp which access a bean class.
the error is :
" Can't access class beans.accesscountbean. Class or interface must be public, in same package, or an accessible member class."
My bean class code is :
package beans;
class accesscountbean {
private String firstPage;
private int accessCount = 1;
public String getFirstPage() {
return(firstPage); }
public void setFirstPage(String fp) {
this.firstPage = fp;
public int getAccessCount() {
return(accessCount++) ; }
Jsp is :
<jsp:useBean id="counter"
class = "beans.accesscountbean"
<jsp:setProperty name="counter"
value="SharedCounts1.jsp" />
of SharedCounts1.jsp(this page),
<A href="sdfsd.jsp">New Page </a>,
<jsp:getProperty name="counter"
property = "firstPage" />
was the first page accessed.
Collectively the has been accessed
<jsp:getProperty name="counter"
property="accessCount" />
Bean is stored in following directory :
Michael Yuan
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
The error message is clear ... You need to say:
public class accesscountbean {
... ...

Seam Framework:
I agree. Here's the link:
subject: Jsp not accessing bean class !
jQuery in Action, 3rd edition