wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes tag file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "tag file" Watch "tag file" New topic
Author

tag file

Abdul Mohsin
Ranch Hand

Joined: Apr 26, 2007
Posts: 111

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>


Regards, Abdul Mohsin
Marcus Green
arch rival
Rancher

Joined: Sep 14, 1999
Posts: 2813
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 ]

SCWCD: Online Course, 50,000+ words and 200+ questions
http://www.examulator.com/moodle/course/view.php?id=5&topic=all
Abdul Mohsin
Ranch Hand

Joined: Apr 26, 2007
Posts: 111

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

Joined: Jul 06, 2006
Posts: 304
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.


Mission SCWCD. Mission SCJP Complete: SCJP 1.4 - 91%
Atul Sawant
Ranch Hand

Joined: Jul 06, 2006
Posts: 304
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

Joined: Oct 21, 2005
Posts: 243
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?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: tag file
 
Similar Threads
Opening File Chooser in a jsp Page?
MoreServlets and Java Server Pages - question
what is empty tag?
tagdir attribute
Question on Tag files