aspose file tools*
The moose likes Servlets and the fly likes Beans working together problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Beans working together problem" Watch "Beans working together problem" New topic
Author

Beans working together problem

scottie zman
Ranch Hand

Joined: Aug 08, 2001
Posts: 40
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
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

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

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
scottie zman
Ranch Hand

Joined: Aug 08, 2001
Posts: 40
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

Joined: Jun 03, 2000
Posts: 5040
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

Joined: Aug 08, 2001
Posts: 40
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

Joined: Jun 03, 2000
Posts: 5040

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

Joined: Aug 08, 2001
Posts: 40
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
anup vachali
Ranch Hand

Joined: Oct 17, 2000
Posts: 54
**hic** whooch side aff the bar **hic**
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

how about a round for the man behind the bar
lemme know when and where...
- satya
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Beans working together problem