• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

jsp:useBean

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I created a sample jsp to use a bean.It is as follows
<%@ page language="java" session="false" %>
<HTML>
<HEAD>
</HEAD>
<BODY>
This is an example of use of JavaBeans.
<jsp:useBean id="per" scope="page"class="Person"/>
</BODY>
</HTML>
I was getting following error when I access using
http://localhost:8080/TestApp/jsp/useBean.jsp
============================== ERROR ============
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 6 in the jsp file: /jsp/useBean.jsp
=================================================
In fact I have placed the class file for Person.java under TOMCAT_HOME/TestApp/WEB_INF/classes, as it does not have package.

The above JSP complies fine if I make Person class part of a package(in my example it is "sungard") and store the class in TOMCAT_HOME/TestApp/WEB_INF/classes/sungard, and change jsp:useBean tag as follows
<jsp:useBean id="per" scope="page"class="sungard.Person"/>

Why is this?.Do I need to configure something else?.I presumed that JSP complier(Jasper) will resolve the class file location using packagaename starting at WEB-INF/classes
Thanks,
Arvind
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It has to do with a common ClassLoader bug. Seems if you don't have a package, the ClassLoader assumes the Bean is in the same package as the class you are in. The package is diferent depending on your server. For you it's apparently jsp.
 
Arvind Chavar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Carl,
Your explanation does help in knowing what is teh cause.
I tried to put the class file for the bean every posssible place in the webapp ,just to see from where it could pick, but it did'nt.Looks like only way was using package.
Thanks,
Arvind
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic