| Author |
JSP file couldn't recognized JavaBeans
|
Timbu Buddu
Greenhorn
Joined: Apr 01, 2003
Posts: 8
|
|
The NumColDate.jsp file uses the bean MyCalendar.java. But when I try to access the bean, I got an error "Undefined variable or class mybean" Here are my files... MyCalendar.java ---------------- package mybeans; import java.util.*; public class MyCalendar{ Calendar c; int year,month,day; public MyCalendar(){ c=Calendar.getInstance(); } public int getYear(){ year=c.get(Calendar.YEAR); return year; } public int getMonth(){ month=c.get(Calendar.MONTH)+1; return month; } public int getDay(){ day=c.get(Calendar.DAY_OF_MONTH); return day; } } NumColDate.jsp --------------- <html> <head> <title> Number, Colors and Date </title> </head> <!--Thispage generates 26 numbers and the displays the date provided --> <body> <%@ page language="java" %> <jsp:usebean id="datebean" scope="page" class="mybeans.MyCalendar" /> <center> DATE year: <%= datebean.getYear() %> month: <%= datebean.getMonth() %> day: <%= datebean.getDay() %> </center> <br> <% for (int i=0;i<26;++i){ %> <%= i %> <% } %> <br> </body> </html> 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
Rancher
Joined: Mar 22, 2000
Posts: 12269
|
|
Importing mybeans.MyCalendar in your page directive might fix this. Bill
|
 |
 |
|
|
subject: JSP file couldn't recognized JavaBeans
|
|
|