I am new to the Tags concept.Why sould we use Jsp Tags and struts tags when we can do the same with scriplets and expressions ?
2) Tags are objects which can be maintained independently of you JSP page. They provide a good mechanism for modularizing your JSP logic, so different pieces can be maintained independently.
Suppose, for example, you application re-uses a "Product" object that needs to be loaded from the database. You could hard-code the load operation directly into your JSP:
Product product = // ... load product data
Or, you could put the logic in a custom tag:
If you use the custom tag approach, and your "load product" logic needs to change, you only need to update the custom tag handler rather than all the JSP. Without custom tags, the only way to modularize JSP is with includes, which is pretty weak.
3) The big disadvantage to custom tags is that they involve more up-front work than simple scripting, because you have to define all your tag handlers. The good news is, these days there are lots of pre-written tag libaries available on the web, so just use those.
Can you really say there is any JSP developer who does not have a Java background????...I think its really not much of an advantage
Can you really say there is any JSP developer who does not have a Java background????...I think its really not much of an advantageI have done this on a real project. A couple years ago, I participated in voice application development, using a combination of VXML, JSP and Java code to access a back-end database. I did not know VXML, and we had several VXML developers that knew no Java.
I put together the business objects, servlets and a handful of custom tags for the VXML developers to use. I showed the VXML developers some simple examples using HTML; it took about an hour to teach them what they need to know about JSP. They went off and wrote the client pages (JSP plus custom tags to produce VXML) while I focused exclusively on the Java code. It all worked.
Just because many companies choice to write their JSP as spaghetti-code messes with lots of scriplets does not mean it has to be that way.
BTW, custom tags are not the only way to get this level of separation. XSLT, Velocity and Tapestry can all be used for a similar effect. I am working on a project now that does a lot of XML manipulation using scriplet-heavy JSP, and I am pushing to get the customer to switch to XSLT with Java pre-processing on the XML to isolate data-retrieval from HTML generation.