wood burning stoves 2.0*
The moose likes Servlets and the fly likes calling a bean object from a servlet into a plain java class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "calling a bean object from a servlet into a plain java class" Watch "calling a bean object from a servlet into a plain java class" New topic
Author

calling a bean object from a servlet into a plain java class

sanjoy sa
Greenhorn

Joined: Aug 19, 2009
Posts: 9
How to access a bean object from a servlet into a plain java class.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

The same way as any other java class. A bean is, after all, just a Java class like any other. What specific difficulty are you having?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sanjoy sa
Greenhorn

Joined: Aug 19, 2009
Posts: 9
I put database details such as sid, user, pswd etc as context param. I called the same in a servlet using listener and put them in a bean object. Now i want to call the object in a pojo to make connection
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

You don't call objects. you call methods. But you still haven't expressed what your issue is.

Are you having trouble passing the bean to another class? Trouble creating the bean in the first place? What's the actual problem?
sanjoy sa
Greenhorn

Joined: Aug 19, 2009
Posts: 9
Thanks Bibeault for your instant response. I will give you the details what I actually want to do:-

My web.xml

---------------
My DBContextListener Class:-
--------------

=====
DB Bean class
-------------

===
====
DBListener where I access the bean object. I tested the out put here which is correct.
-------------------------



===========


POJO Class where I want to access the bean object for further processing.
//db will be the object of the DB class.jdbc and odbc i will define here.
------------------------



}
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

Please be sure to use code tags when posting code to the forums. Unformatted or unindented code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please click this link ⇒ UseCodeTags ⇐ for more information.

Properly indented and formatted code greatly increases the probability that your question will get quicker, better answers.
sanjoy sa
Greenhorn

Joined: Aug 19, 2009
Posts: 9

Thank You for your suggestions for using code tags. It is really useful.
Now let me show my problem in details:

My web.xml






---------------
My DBContextListener Class:-
--------------




=====
DB Bean class
-------------


====
DBListener where I access the bean object. I tested the out put here which is correct.
-------------------------



===========


POJO Class where I want to access the bean object for further processing.
//db will be the object of the DB class.jdbc and odbc i will define here.
------------------------

 
Don't get me started about those stupid light bulbs.
 
subject: calling a bean object from a servlet into a plain java class
 
Similar Threads
servlet setting some value need to retrive that value in a normal java file
EJB3 Dependency Injection: How to write ApplicationClient injecting @EJB correctly ?
Cannot get HttpSessionBindingListener method valueBound to trigger
how to call servlet class from an action class?
help---please