Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When can I use custom tag prefixes

 
Carmen Brianick
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I just want to confirm 2 things on tag prefixes:

1. If I created my own tld and tag, I can do:
<%@ taglib prefix="mineOwnPrefix" uri="randomLocation"%>
<mineOwnPrefix:setMyText user="${userName}"/>

2. If I use the tld's provided by JSTL: Then I cannot use my own custom prefix like:
<%@ taglib prefix="mineOwnPrefix" uri="http://java.sun.com/jsp/jstl/core"%>
<mineOwnPrefix:forEach> ...

Am I right? I just got confused with when I can use my prefix and when I cannot.

Thanks so much,
Carmen
 
Satish Ramasamy
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can always use your own custom prefixes. There is no restriction on that.
 
Frederic Esnault
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can use the core library with another prefix than c. This is just a "convention". You can set the JSTL core library to whichPrefixShouldI then call tags with :

<whichPrefixShouldI:choose>
...

Sorry bad joke.

But the prefix is actually whatever you want.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not following the conventions will make your coworkers very unhappy.
 
Vishwas Hegde
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Not following the conventions will make your coworkers very unhappy.


Which might affect your appraisal also
 
Carmen Brianick
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Frederic, thanks for your reply. However, in the Chapter 9 Mock Exam for HFSJ book, wasn't there a question where only the choice with <c:set > was the answer and no other choice. I have to get the exact question and I'll post a question with that. Do you know which question I'm referring to?

BTW, thanks so much for your study guides, Many thanks!!!
Carmen
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic