This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Unable to found class

Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai friends ,
i am using tomcat 5.0.28 . i have written simple jsp page as follows ,

<title> :: Sample page </title>
<%= Sample.getData() %>


here Sample is the class without any package structure as follows ,
public class Sample {
public static String getData() {
return "From Sampl.class" ;

i have put this class file immediately under the classes directory of WEB-INF .
When try to access sample.jsp the following error is occur...
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 1 in the jsp file: /sample.jsp
Generated servlet error:
/home/bala/jakarta-tomcat-5.0.28/work/Catalina/localhost/IMS/org/apache/jsp/ cannot resolve symbol
symbol : variable Sample
location: class org.apache.jsp.sample_jsp
out.print( Sample.getData() );
1 error


But if i create this Sample class under some package structure
(ie., like pack.Sample ) it is working fine ..

wht is the wrong in this ...?

thanks in advance.
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot access a class in an unnamed (default) package as per JSP 2.0 Specification]. See the following excerpt from JSP Specification Section JSP.11.2 (Page #255 of the pdf).

As of JSP 2.0, it is illegal to refer to any classes from the unnamed (a.k.a.
default) package. This may result in a translation error on some containers,
specifically those that run in a JDK 1.4 or greater environment. It is unfortunate,
but unavoidable, that this will break compatibility with some older JSP
applications. However, as of JDK 1.4, importing classes from the unnamed
package is not valid (see
for details). Therefore, for forwards compatibility, applications must not rely on
the unnamed package. This restriction also applies for all other cases where
classes are referenced, such as when specifying the class name for a tag in a TLD.

Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!