• 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

Custom Tags

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
You are using a tag library with prefix "generator" which supports a tag named "random". This tag generates a random number and sets it to a variable named "value". Which of the following will output this value in the page?
The answer is <generator.random><%=value%></generator.random>
Please, can somebody write a example of how do a tag library with prefix "generator" and a tag named "random"?
Thank you in advance
 
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jordi,
what are the other wrong answers? Maybe then its easier to discuss.
Axel
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I think that the question is not how I would like because my english is not good.
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jordi:
I don't think the ans is correct, atleast I don't know how to write such a tag...
However, the closest example code I could get is enclosed here.
Files:
  • RandomNumExample.jsp: Put this in %Catalina_Home%\webapps\Root\jsp-intro
  • random-taglib.tld: Put this in %Catalina_Home%\webapps\Root\WEB-INF
  • web.xml: Put this in %Catalina_Home%\webapps\Root\WEB-INF
  • RandomTag.java: Compile this file and put the RandomTag.class file in %Catalina_Home%\webapps\Root\WEB-INF\classes\madhav\tags


  • Then you can access it through the URL:
    http://localhost:8080/jsp-intro/RandomNumExample.jsp

    This is the closest example I could getto, with the explanation given.
    - satya
    ps:
    As you can make out, this example is based on an example from More Servlets and JSP's book.
    [ February 05, 2002: Message edited by: Madhav Lakkapragada ]
     
    Anonymous
    Ranch Hand
    Posts: 18944
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thank you very much Madhav
     
    Sheriff
    Posts: 5782
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I am not a tag-guru, but I know JSP tag usage rules follow XML standards. Most certainly the "prefix" here means a namespace declared by the taglib. In XML, tags belonging to a namespace are always qualified with "prefix:"
    So whatever is the expression for invoking the java code, the enclosing tags should be of the form
    <generator:random>
    something here
    </generator.random>
    [ February 07, 2002: Message edited by: Ajith Kallambella ]
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic