Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

tag file

 
Abdul Mohsin
Ranch Hand
Posts: 111
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • 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>
 
Marcus Green
arch rival
Rancher
Posts: 2813
  • Mark post as helpful
  • send pies
  • 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
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • 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.
 
Atul Sawant
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Renu Radhika
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic