This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JSP and the fly likes JSP file couldn't recognized JavaBeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » JSP
Bookmark "JSP file couldn Watch "JSP file couldn New topic

JSP file couldn't recognized JavaBeans

Timbu Buddu

Joined: Apr 01, 2003
Posts: 8
The NumColDate.jsp file uses the bean But when I try to access the bean, I got an error "Undefined variable or class mybean"
Here are my files...
package mybeans;
import java.util.*;
public class MyCalendar{
Calendar c;
int year,month,day;
public MyCalendar(){
public int getYear(){
return year;
public int getMonth(){
return month;
public int getDay(){
return day;

Number, Colors and Date
<!--Thispage generates 26 numbers and the displays the date provided -->
<%@ page language="java" %>
<jsp:usebean id="datebean" scope="page" class="mybeans.MyCalendar" />
year: <%= datebean.getYear() %>
month: <%= datebean.getMonth() %>
day: <%= datebean.getDay() %>
<% for (int i=0;i<26;++i){ %>
<%= i %>
<% } %>

Directory Structure
1. Tomcat/webapps/JSP/NumColDate.jsp
2. Tomcat/webapps/JSP/web-inf/classes/mybeans/ NumColDate.jsp
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13001
Importing mybeans.MyCalendar in your page directive might fix this.
I agree. Here's the link:
subject: JSP file couldn't recognized JavaBeans
It's not a secret anymore!