• Post Reply Bookmark Topic Watch Topic
  • New Topic

where's my class?

 
Daniel Lynn
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65518
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Dilip kumar
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Posts: 65518
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 65518
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!