• 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

Passing a bean in a custom tag

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good night,

I am trying to create a webpage using Java Beans and Custom Tags. I have this bean that will create a connection to the database and keep it open so that it sends a reference to the statement object when necessary.

However, I want to create custom tags such as <tag:login username="something" password="something" /> which will compare that information to the database and base the content on that.

However, I have no idea as to how one can get to have access to the methods in the bean from the tag object. Can this be done? If not, how could I do something like this by using custom tags?
 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're using JSP 2.0, you can use EL to access the property of a bean. Something like this:



If you're not using JSP 2.0, you could still use scriplet expression in your attribute (provided you set rtexprvalue to true). Something like this:



HTH.
 
Jos� Alberto Mu�iz Navarro
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But I want to pass a reference to the SQL Connection. Hence, if I just send some text as an attribute, I don't see how that would serve my purpose. Could you possibly explain me how I could actually make it so that the connection is available for being used over there, along with all its methods.

Thank you very much for your assistance.
reply
    Bookmark Topic Watch Topic
  • New Topic