Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Where does the JSP search for classes?  RSS feed

 
Matloob Hussain
Ranch Hand
Posts: 37
Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
My code does not work when I use Counter.java class without any package. When I use foo package then it works by finding Counter class in directory "WEB-INF/classes/foo/" but when I don't use foo package then I should find Counter class from directory "WEB_INF/classes" but it does not work and one thing more, do we need to use import attribute in page directive when we are not using any package. all java classes in classes directory.

Counter.java class

JSP code
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65898
135
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All Java classes used in web apps needs to be in a package other than the default.
 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys! I didn't know this before. However, I have a habit of keeping my classes in some package. So, never thought about this. Thanks again!
 
Matloob Hussain
Ranch Hand
Posts: 37
Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it, Thanks alot.....
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!