• Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom Tag in Servlet  RSS feed

 
L Goundalkar
Ranch Hand
Posts: 395
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I have implemented Custom Tag for sending email. I can use it easily in JSP. But how can I use it in Servlet?
Do I need to create equivalent Bean class having implementation or is there anyway I can use custom tag implementation in Servelt directly ?
Cheers.
 
Andy Bowes
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Custom Tags can only be placed on JSP pages they cannot be invoked from servlets. I think the best way would be to move the body of your code to a JavaBean that can be invoked either from the Custom Tag or from a servlet or any other Java code.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Someone could argue that since the interfaces to the custom tag code are public, that you could invoke your custom tag code in a similar fashion to the way the servlet generated for a JSP would. However, since no page context exists for a servlet, you'd have to do a lot of fancy footwork to fake it all.
Needless to say, the easier -- and most correct -- thing to do would be to logically refactor your code for sharing as Andy suggested.
hth,
bear
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!