Whis one to use among JSP, servlet, TAGS??


Web tier: servlets, JSP, Web frameworks: Whis one to use among JSP, servlet, TAGS??

  1. Whis one to use among JSP, servlet, TAGS?? (1 messages)

    Most of the Java code in scriptlets can be extracted and put in either servlets or TAGS. What portion of the code should remain in JSP? What should go in the Sevlets and what should be replaced by TAGS? What is the best practice?
    Under which circumstances the, you go from one choice to other?

  2. Vipul, the answer to your question depends on a number of factors and is subject to debate. In general, you try to keep scriptlet code in your JSP's to a minimum and then only use it to assist in data display; try not to place business logic in your JSP's. You've probably heard that mantra before.

    Custom tags are real handy, but I can see how one might go overboard with them. I've written several and realized it's tempting to rely too heavily on them. I'd suggest developing tags that are somewhat generic and therefore reuseable - either reuseable in other pages of the same application or in other applications.

    Servlets are now used more frequently as 'glue' to hold the various pieces of an application together. You may not need them much at all if your application is small, but frequently they're used to as controllers, mediating between JSP's and java beans that perform the business processes. Sun's "Blueprint" talks at length about this topic, as do several other good books. For Sun's approach, see: http://java.sun.com/j2ee/blueprints/apmTOC.html. Check out chapter 4.3.