Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where does the JSP search for classes?

 
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
Pie
Posts: 65113
89
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.....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic