Forums Register Login

How to acess a packaged bean in a servlet

+Pie Number of slices to send: Send

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
+Pie Number of slices to send: Send

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.
+Pie Number of slices to send: Send
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.


Mo-om! You're embarassing me! Can you just read a tiny ad like a normal person?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 783 times.
Similar Threads
Enterprise bean environment mechanism
long post IBM.158
JEE5 bean and war deployment
iPLanet + JSP
Regarding loading of servlets
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:02:25.