you can put them anywhere, as long as the directory they are located in
is in Tomcat's classpath ...reference them using the
<jsp:useBean> directive in your JSPs...
Arif Tayebali wrote:
> Does anyone know where to place JavaBeans in Tomcat??
> And how do I reference these Beans from JSP pages??
> And are these beans are to be saved as .class files??
>
> Tomcat is located at D:\Tomcat
> Webapps is located at D:\webpage\jsp
>
> I have compiled my Beans and placed them in the
>
> D:\Tomcat\webapps\examples\WEB-INF\classes dir
>
> But receivee this error at runtime:
>
> Root cause:
> java.lang.ClassNotFoundException: Unable to load class TimeBean
>
> The bean looks like this:
>
> public class TimeBean {
>
> private int hours;
> private int minutes;
>
> public TimeBean() {
> java.util.Date now = new java.util.Date();
> this.hours = now.getHours();
> this.minutes = now.getMinutes();
> }
>
> public int getHours() {
> return hours;
> }
>
> public int getMinutes() {
> return minutes;
> }
>
> }
>
> and the jsp file looks like this:
>
> <jsp:useBean id="help" scope="session" class="TimeBean" />
> <jsp:setProperty name="help" property="*" />
>
> <html>
> <body>
> You entered the input, <b><jsp:getProperty name="help"
> property="minutes"/></b><br>
> </body>
> </html>
>
> Thanks in advance!