• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Beans working together problem

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have a newbie question related to a bug tracking jsp app I'm working on.
I wrote some beans and want them to work together. for instance, one bean, dbBean, is for databases and another bean, bugBean, is for getting bug tracker form info from a user.
I know that from the JSP itself I can make the beans work together... ie, populate bugBean, then create a SQL string, give it to dbBean, which runs the query, etc... but what I want is for bugBean to access dbBean directly, so I can call a function like bugBean.insert().
The Problem: From the beans, I haven't been able to import them into one another. I tried setting the classpath to point at the web-inf/classes directory but it still doesn't work; bugBean won't compile because it can't find dbBean.
Can someone please explain what I need to do in order to get cooperation between my beans?
Thanks
Zman
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

bugBean won't compile because it can't find dbBean.
Write your java code in proper packages.
Use javac to compile the classes seperately(for this
you might have to set the proper classpath). Then
copy all the .class files to the proper
dir's under web-inf/classes dir.
If you are familiar with tools like ant
they do all this for you. All you need to do is to
specify the correct parameters.
regds.
- satya
 
scottie zman
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm, that's what I've been doing. I have a directory in /classes called sqlBeans, which contains the dbBean class, which is in the sqlBeans package. a similar thing for the other class. And so I try "import sqlBeans.DbBean" or "import sqlBeans.*" and it's not finding it.
Thanks for the help-- I _think_ I'm on the right track... I'll look into it further as I am a greenhorn.
Zman
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll look into it further as I am a greenhorn.
being a javaranch greenhorn should have nothing
to do with this...hopefully you agree...
ummm....I was suggesting that you create your java files
outside of the classes folder. Not in tomcat folders,
just something else. Then compile the classes from the
your root dir. I would do something like this:

Then copy the class files to the appropriate
dirs under classes or better off jar them up
and copy the jar file to the web-inf\lib
dir.
Let us know if this doesn't help.
One last note, even if you are doing this in the
Tomcat dir's, your myRoot dir (absolute path)
should be in your classpath.
- satya
 
scottie zman
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmmm that's getting over my head. time to dive in! I need to understand packages -- because it seems kind of strange to have the class in two different places: why compile it in the java root and then move it, how does that facilitate the beans working together, and which version of the class is being accessed? seems a little tedious. the wrox books should be here soon thanks for not turning up the flamehrower to extra crispy. most newbie-type posts result in rather harsh reactions from those in the know. but being that you're a bartender here, I guess you've heard it all. thanks a lot for your help.
Zman
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

why compile it in the java root and then move it, how does that facilitate the beans working together, and which version of the class is being accessed? seems a little tedious.

The reason I suggested this is because this way you know
whats wrong with your packages, not mixed with Tomcat.
You will be working on some java clases (called beans in
this case) on thier own, like anyother java files.
Sure it is tedious. To make it easy there are tools like ant which infact do this for you. Except that you need to
spell out the dir correctly.
Its not that bad (actually not bad at all). And one other
thing, you don't have to be in the myRoot dir, if thats
in your classpath.
Good luck with the Wrox books.
(Worx books scare me, just too bulky)
- satya
 
scottie zman
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks so much...
I figured it out, I was setting the path and not the classpath, darrrr. Now my beans are talkin'.
how about a round for the man behind the bar
-Zman
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
**hic** whooch side aff the bar **hic**
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

how about a round for the man behind the bar
lemme know when and where...
- satya
 
Yeast devil! Back to the oven that baked you! And take this tiny ad too:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic