• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

where's my class?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no idea what's going on here...

I have a simple jsp page calling a simple class. The class's entire code is:

public class varSettings {
public static int testVar=16;
}

and it's in the $catalina_home/common/classes directory on my Tomcat server and in my jsp page I put

out.print(varSettings.testVar);

and I get the following error:

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 54 in the jsp file: /index.jsp
Generated servlet error:
/usr/local/jakarta-tomcat-5.0.28/work/Catalina/www.newworldfreedom.org/_/org/apache/jsp/index_jsp.java:192: cannot resolve symbol
symbol : variable varSettings
location: class org.apache.jsp.index_jsp
out.print(varSettings.testVar);
^
1 error

I've had a few other people look at it and we're all pretty confused. If anyone can provide any help, it'd be awesome!! Thanks.

-Dan
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Firtly, place the class in a package other than the default. The container cannot access classes that are in the default package.

Secondly, it's a good idea to following standard naming conventions. Therefore your class should be named VarSettings as opposed to varSettings.
 
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't you guys think varSettings class needs to be instantiated prior accessing testVar?
[ May 26, 2005: Message edited by: Dilip kumar ]
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instantiation has nothing to do with compile-time errors. Besides, he's referencing a static field; no instantiation necessary.
 
Daniel Lynn
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That worked. I was sure I tried that, but obviously I didn't. Thanks.

-Dan

PS - I changed the v to V -- good to keep with conventions I suppose
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad to hear that that solved your problem.

good to keep with conventions I suppose



It is! While it may seem like a small thing -- not following gnerally accepted Java naming conventions can make your code incredibly difficult to decipher for others.
[ May 27, 2005: Message edited by: Bear Bibeault ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic