I have stored the bean class in the destination derictory of my server from where my jsp page locates it and for that i had to make my beans as a packaged one like this adding this line before import statements of my bean package sunexamples.beans; because my bean is in sub-directory of sunexapmples which is beans and my bean class resides there Now If i want to use the same bean class in side my servlet I am giving its full path name but it is not able to locate it I tried calling it through this way sunexamples.beans.mybean b = new sunexamples.beans.mybean(); and this way also classes.sunexamples.beans.mybean b = new classes.sunexamples.beans.mybean(); but compiler is not able to locate it Im totally confused how to access my bean through servlet
SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
Sounds like a classpath problem. Make sure the directory containing sunexamples is in the classpath for the servlet container. Also in your servlet, you can import your package. Then you won't need to reference yourbean by the whole package name everytime.
Joined: Jun 09, 2000
I imported the package also actually I am using javawebserver2.0 and this bean is in directory c:\javawebserver2.0\classes\sunexamples\beans I am trying to import the package sunexamples.beans like import classes.sunexamples.beans; or import sunexamples.beans; then it says cannot resolve symbol beans (compiler error) I tried setting my classpath by adding a line in front of existing classpath like this c:\javawebserver2.0\classes\sunexamples\beans (I m using Windows NT) still nothing seems to work
Originally posted by Andrew Shafer: Sounds like a classpath problem. Make sure the directory containing sunexamples is in the classpath for the servlet container. Also in your servlet, you can import your package. Then you won't need to reference yourbean by the whole package name everytime.
subject: How to acess a packaged bean in a servlet