Hi, Since JSP's are made on the Servlet Technology,I suppose, we can always say whatever can be done through JSP the same would be possible through Servlets However, the concept of Taglibs is absent in Servlets.Can we call Taglibs in the Servlet code? Since TagLibs might contain some business logic, which the page-makers usually use to incorporate in the pages, it would be great if similar sort of facility would be available through servlets Thanks in advance,
You correctly note that since JSP's are ultimately translated into servlets, you can do anything with servlets. You can theoretically call custom tags from within a servlet, if you're willing to do a lot of work, but the syntax is ugly. All you have to do is duplicate the calling sequence that the JSP container generates:
You would have to implement the PageContext with your own class. If you have code in a tag handler that you want to use in both environments, you would be better off implementing it in a pure Java Beans model class, which you call from the tag handler. That way, you could call the model from a servlet without having to go through the semantics of the taglib code. ------------------ Phil Hanna Sun Certified Programmer for the Java 2 Platform Author of : JSP: The Complete Reference Instant Java Servlets Website: http://www.philhanna.com
Phil Hanna<BR>Sun Certified Programmer for the Java 2 Platform<BR>Author of :<BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072127686/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072124253/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
Originally posted by Phil Hanna: you would be better off implementing it in a pure Java Beans model class, which you call from the tag handler.
Yeah it is easy to use Java Object's in servlet rather going for the tag handler which makes things complicated. I dont see any advt. using tag handler in Servlet......is there any??
SCJP 1.5, SCEA, ICED (287,484,486)
Joined: Apr 02, 2001
Thanks Phil and Anil for your response. Anil, as I said in my earlier post, we have some business logic in the taglibs.From the responses that you and Phil gave, should I infer that, if I have to call my business logic in Servlets and JSP, I would be better off to put that piece of code in the JavaBean (ofcourse,EJB would be the best solution!!) rather than the taglibs. Thanks in advance, ------------------ Sandeep Desai firstname.lastname@example.org
Sun Certified Java ProgrammerScored 93 per cent
Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
IBM Enterprise Connectivity with J2EE Scored 72 per cent
Enterprise Development on the Oracle Internet Platform Scored 44 out of 56