• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to access a bean object from a servlet into a plain java class.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
------------------------

 
Come have lunch with me Arthur. Adventure will follow. This tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic