• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Tag Files : why TLD requires

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all
i have small doubt regarding tagfiles. It is specified that if the tagfile is residing inside the jar then we require a TLD in which we use the <path> to tell the container the location of the tag file. However when we use the tag file then we write in the jsp as

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

this is what we write in the jsp file to use the tagfile.

Now I have two questions regarding it

1) If we can specify the tag file location as above then why dont we can specify the tag file location for the tag files which are packed in the jar. ie

<%@ taglib prefix="mine" tagdir="/META-INF/tags" %>

if this is possible then there is always one standard way of telling the container about the location of the tag file.

2) and if we need TLD ( any ways: for the case where tag file is in jar ) then what should be the value of the tagdir = ? in the jsp file to use the tag file.
thanks in advance
jitin
 
Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Jitin.

1) If we can specify the tag file location as above then why dont we can specify the tag file location for the tag files which are packed in the jar. ie

<%@ taglib prefix="mine" tagdir="/META-INF/tags" %>



If the tag file is not present in jar file, we can use 'tagdir' attribute, specifying where the location of tag file is present i.e by using tagdir="/WEB-INF/tags". Now the container/server goes there and search for tag file.

If the tag file is present in jar, we should place it under /WEB-INF/lib/ directory(like /WEB-INF/lib/myTagFile.jar). If we say tagdir="/META-INF/tags", it will not able to find the tag file. Inorder to search for tag file, the container must need a reference, where the actual tag file is present. That's why we use .tld file for specifying the location of the tag file.

2) and if we need TLD ( any ways: for the case where tag file is in jar ) then what should be the value of the tagdir = ? in the jsp file to use the tag file.


In that case I think, we should not use 'tagdir' attribute. We should use 'uri' attribute instead, as incase of JSTL tags usage.
 
Jitin Guglani
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi chinmaya
thanks for your reply. My question is exactly what your repsonse is ie why container is not able to lacate the tag file if it is inside the jar file because if container is able to do this simple job then there is one universal way of specifying the tag file location and it helps me remember less for the exam .So i was asking actually that why container is not able to locate from jar file even though it can read the jar.
Second as you said that instead of specifying the tag-dir specify the uri but uri is for the tags not for tag-files i think. Kindly check this again.
thanks and regards
Jitin
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you checked what the JSP Specification has to say about this?
 
Jitin Guglani
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. I am very new and amature to read the specs . I was going through Head First Servlets and JSPs .
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whenever you have "why" questions such as this, the JSP Specification is the source of all knowledge.
 
Jitin Guglani
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes sir i know that jsp spec is the ultimate authority and i would love to read it as it is the Bible of JSP , but for the time being till I am not able to collect the information regarding this from jsp spec, if you know the answer please tell me so that I can continue my chapter without break.
I will give you my promise to finish the spec once i will finish the book
thanks and regards
jitin
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The simple answer is that the Spec doesn't say that's the way it will work. So it doesn't.
 
Marshal
Posts: 28295
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"I don't have time to read the documentation" is never a valid excuse.
 
Jitin Guglani
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sir I think that you have either not read my question and my replies carefully or you do not understand my problem.
The only difference is that tag-file is jar and container is able to read the jar then why we need to implement in the different way ie why JSP designers choose to implement this in the special way . what were conditions that forced them to have such a different method.
I do not see any limitation of the containers to read the jar file. why cannot we simply define the location of the jar file with tag-dir attribute.
I got your point that specs says that it is the way but my question is why this way is required.
 
Jitin Guglani
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mr Paul
I have never said that I dont have time to read the specs. I said that I am not that mature to read the specs. I am an amture . And gradually I will become mature to read the specs.
As a matter of fact I am going through some simpler book Head First Servlets and JSP so that I will have overall look and feel of JSP and then have to move on specs as Mr Bear has suggested.
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jitin Guglani wrote:but my question is why this way is required.


You'll need to ask the authors of the Spec for that.

There could be literally thousands of questions along the lines of "why did they do this?", or "why did they do that?".

In some cases we might be able to take a good technical guess as to why the Spec was couched in a certain way, but for many the answer is just "That's what was decided upon."
 
Jitin Guglani
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Mr Bear , I totally agree with you. but I thought by chance if some know (or some Jsp designer who is member of this site ) about it and my doubt will be clearified. But any how thanks a lot for valuable time.
regards
Jitin
 
Chinmaya Chowdary
Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Jitin.

Second as you said that instead of specifying the tag-dir specify the uri but uri is for the tags not for tag-files i think.


As far I know we should use 'uri' attribute if the tag file is present in jar file. Please correct me, if I made mistake.

why container is not able to lacate the tag file if it is inside the jar file because if container is able to do this simple job then there is one universal way of specifying the tag file location


Container can locate, there is no problem. First thing we should remember is tag file's are created to simplify the job of page designers.

Suppose we made a tagFile named it with Image.tag and store it in package 'com.pack1.foo.bar.Image.tag'. We compile it, (here if we don't make .tld file for specifying where the tag file is present) and made a jar file named 'imageTagFile.jar'. Inorder to use this 'imageTagFile.jar' file in one of our jsp's, we have to use the page directive like Then container will be able to search for the tag file and serves our purpose. As a java programmer specifying the above page directive is simple. For page designer's it is not. Their main role is for creating creative, beautiful web pages. They don't need to know java.

Inorder to simplify the role of page desiners, I think 'sun' made a .tld file, specifying where the location of tag file is present. By using this, it is simple to use, we simply specify tag directive like
This way is simple for page designers.
 
Jitin Guglani
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi chinmaya.
I think this is the most logical and appropriate reason. That is why the designers design it in this way. . And yes with tag-files we can use uri.
thanks and regards ( and yeah Happy Diwali )
Jitin
 
Here. Have a potato. I grew it in my armpit. And from my other armpit, this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic