• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

tag file

 
Ranch Hand
Posts: 111
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can anybody tell me what are the benefits of including .tag file using taglib directive ( page 495 HF) as compared to <jsp:include> and <c:import>
 
arch rival
Posts: 2813
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One of the benefits is that they are simpler, i.e. they can be nothing but plain HTML with no JSP content at all and you don't have to mess with creating a tld file for them.
[ July 09, 2007: Message edited by: Marcus Green ]
 
Abdul Mohsin
Ranch Hand
Posts: 111
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

One of the benefits is that they are simpler, i.e. they can be nothing but plain HTML with no JSP content at all



but these simple plain HTML files can be included using include directive then exactly what befefits we will get by using tag file include.
 
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One noticeable benefit you get using tag files is that the parameter which you pass to the included file is not added to the request object...

for eg:

this is the file to be included...

include.jsp

<html>
welcome ${param.username}
</html>

in the mainpage where you are including the page...

<jsp:include page="include.jsp">
<jsp aram name="username" value="Atul"/>
</jsp:include>

now the parameter username is attached to request object and that is why can be available at request scope to anyone.

if you introduce include.tag

<%@ taglib prefix="tags" tagdir="/technology/WEB-INF/tags" %>

<tags:include username"Atul"/>

in include.tag


<%@ attribute name="username" required="true" %>


Welcome ${username}


The parameter "username" is then only available to the tag file "include.tag" ...no one else.

Nothing great about it but just matter of performance.
 
Atul Sawant
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
using <c:import> you can import/include a file located beyond the web application.

You can also use relative path to access the file which located at another web appl. using attribute 'context'

check...

http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/c/import.html
 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont agree with the request parameter scope.The passed parameter in jsp:include is also available in the included page only.I had posted this question sometime back.But I didnt get any reply on what the actual difference is?
 
reply
    Bookmark Topic Watch Topic
  • New Topic