Originally posted by kishore chitturi: Hi Chowdary, Thank u for giving reply.We are using jsp:useBean tag for reusing,then why we need customtags.Can u explaing this one.
If I understand you correctly, you are asking what the difference is between standard actions, such as <jsp:useBean> and custom tags. They are actually two very different things.
<jsp:useBean> is a standard action tag. There are other standard actions out there too, for instance <jsp:include> and <jsp:forward>. Each standard action tag provides a functionality reduces the need for scripting inside a jsp page. Specifically, <jsp:useBean> is used primarily for retrieving (or creating) attribute objects. When you use it, the Container looks for a matching attribute object in the specified scope. If no scope is specified, it uses the default page scope. If one does not exist, it will create a new instance of the class specified and make it an attribute (again in the specified scope).
Sometimes, however, you need more than the standard action tags can provide (or JSTL for that matter). That is when you can resort to custom tags. Now you can create your own tags to do what the standard ones could not. What if, for example, you had a database that stored all of your music files in it, and you wanted a jsp page to display the artist and song title based on some criteria given (like maybe the first letter of the song?)? You could create a custom tag that preformed the database search based on the criteria supplied and then iterated over the results, outputting the songs in table format. the in your jsp page, you would only have to use an EL expression to get your effect:Hope that helps clear it up!
“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook