• Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing a bean in a custom tag  RSS feed

 
Jos� Alberto Mu�iz Navarro
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • 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?
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
  • 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
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!