[Logo]
Forums Register Login
calling a bean object from a servlet into a plain java class
How to access a bean object from a servlet into a plain java class.
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?
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
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?
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.
------------------------



}
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.

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.
------------------------

Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Nov 19, 2017 11:12:43.