Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Another class instance in JSP

 
Sandeep Chhabra
Ranch Hand
Posts: 340
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am a newbie in JSP, Could you please tell me how can I create an instance of a class (which is in the default package) in JSP.
whenver I try to do it, i get an error saying the class not found?

how can i do it?

thanks
 
Christopher Elkins
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've had issues with this myself. My resolution was to create a package and put the class in it. Which works just fine and seems to me to be a preferential way of coding since it allows you to group your classes by functionality. Just my two cents. If you want to keep it in the default package I can't help. Sorry.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't. The class must be in a package other than the default.
 
Sandeep Chhabra
Ranch Hand
Posts: 340
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I tried that too...

But the problem persists...

I put the class in a package...and then reffered to that class as package.classname

still it says package.classname not found.

what should i do now?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you putting the class file in the proper folder? Have you reviewed the JSP FAQ entry on this subject?
 
jiju ka
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might not be using the import.

A code snippet follows. Observe how the StringBuffer and List is imported.



whatever in java.lang need not be imported
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic