• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
sanjoy sa
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to access a bean object from a servlet into a plain java class.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64615
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
sanjoy sa
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64615
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64615
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic