my dog learned polymorphism*
The moose likes JSP and the fly likes Another class instance in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Another class instance in JSP" Watch "Another class instance in JSP" New topic
Author

Another class instance in JSP

Sandeep Chhabra
Ranch Hand

Joined: Aug 28, 2005
Posts: 340
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


Regards<br />Sandy<br />[SCJP 5.0 - 75%]<br />[SCWCD 1.4 - 85%]<br />------------------<br />Tiger, Tiger burning bright,<br />Like a geek who works all night,<br />What new-fangled bit or byte,<br />Could ease the hacker's weary plight?
Christopher Elkins
Ranch Hand

Joined: Oct 26, 2004
Posts: 45
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.


Christopher Elkins, SCJP Java 2 Platform
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

You can't. The class must be in a package other than the default.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Sandeep Chhabra
Ranch Hand

Joined: Aug 28, 2005
Posts: 340
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

Joined: Jan 10, 2002
Posts: 60822
    
  65

Are you putting the class file in the proper folder? Have you reviewed the JSP FAQ entry on this subject?
jiju ka
Ranch Hand

Joined: Oct 12, 2004
Posts: 306
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Another class instance in JSP
 
Similar Threads
(URGENT) Singletons and JSP pages
Sequence of Elements in the JSP Life Cycle
Regrading JSP's
how to allow jsp and applet to access SAME object instance ..
Contruct a sub class instance from a super class instance.