| 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: 56529
|
|
|
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?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About 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: 56529
|
|
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: 56529
|
|
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.
------------------------
|
 |
 |
|
|
subject: calling a bean object from a servlet into a plain java class
|
|
|