We are doing a custom JSTL custom tag to make display page to access a tag handler.   Write two custom tags: 1) A single tag which prints a number (from 0-99) as words. Ex:    <abc:numAsWords val="32"/>   --> produces: thirty-two   2) A paired tag which puts the body in a DIV with our team colors. Ex:    <abc:teamColors school="gophers" reverse="true">     <p>Big game today</p>     <p>Bring your lucky hat</p>      <-- these will be green text on blue background   </abc:teamColors> Details: The attribute for numAsWords will be just val, from 0 to 99   - spelling, etc... isn't important here. Print "twenty-six" or "Twenty six" ... .  Attributes for teamColors are: school, a "required" string, and reversed, a non-required boolean.   - pick any four schools. I picked gophers, cyclones, hawkeyes and cornhuskers   - each school has two colors. Pick whatever seems best. For oine I picked "cyclones" and       red text on a gold body   - if reverse is set to "true", the colors should be swapped (gold text on red body, in my case).   - note that non-required values have defualt values. In other words, you can safely check     if(reversed==true) without worrying about a null error. You won't know whether they left it out,     or wrote reversed="false", but it doesn't matter. There will be a total of 4 files:  ) A .tld holding descriptions. This will be made and updated automatically. ) A class for numAsWord (made as a TagHandler) ) Another class for teamColors (same) ) a test .jsp file, using these 2 tags.   [6]teamColors works as a tag and changes the body or text to any color (maybe always green)[4]teamColors uses "school" to select&use two colors[6]Four possible teams[4]reverse="true" switches the colors [6]numAsWord works as a single tag and does anything (maybe always "number here")[4]it works for some numbers[6]it works for 0 to 99[4]it Uses a StringBuilder to make the word   <--- the only place I mention this   --- Notes: o For the numbers, I used several arrays: My arrays were 0-9 as words, the tens place words (ten, twenty ... ) and the   special teens words (eleven ... ) Getting fancy by auto-adding "teen" to "fif" and "six" ... seems like too much.  I used a big nested-if:   0-9 is a thing, 11-19 are special "teens" words, otherwise it's:     "tens string" "ones string" (like "forty" plus "seven")   And of course, a one's place of 0 is a special case (so we don't print sixty-zero)

New Perspectives on HTML5, CSS3, and JavaScript
6th Edition
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Patrick M. Carey
Chapter3: Designing A Page Layout: Creating A Website For A Chocolatier
Section3.3: Visual Overview: Layout With Positioning Styles
Problem 4QC
icon
Related questions
Question

We are doing a custom JSTL custom tag to make display page to access a tag handler.

 

Write two custom tags:

1) A single tag which prints a number (from 0-99) as words. Ex:

   <abc:numAsWords val="32"/>   --> produces: thirty-two
   
2) A paired tag which puts the body in a DIV with our team colors. Ex:

   <abc:teamColors school="gophers" reverse="true">
     <p>Big game today</p>
     <p>Bring your lucky hat</p>      <-- these will be green text on blue background
   </abc:teamColors>

Details:
 The attribute for numAsWords will be just val, from 0 to 99
   - spelling, etc... isn't important here. Print "twenty-six" or "Twenty six" ... .
 
 Attributes for teamColors are: school, a "required" string, and reversed, a non-required boolean.
   - pick any four schools. I picked gophers, cyclones, hawkeyes and cornhuskers
   - each school has two colors. Pick whatever seems best. For oine I picked "cyclones" and
       red text on a gold body
   - if reverse is set to "true", the colors should be swapped (gold text on red body, in my case).
   - note that non-required values have defualt values. In other words, you can safely check
     if(reversed==true) without worrying about a null error. You won't know whether they left it out,
     or wrote reversed="false", but it doesn't matter.

There will be a total of 4 files:

 ) A .tld holding descriptions. This will be made and updated automatically.
 ) A class for numAsWord (made as a TagHandler)
 ) Another class for teamColors (same)
 ) a test .jsp file, using these 2 tags.

 

[6]teamColors works as a tag and changes the body or text to any color (maybe always green)
[4]teamColors uses "school" to select&use two colors
[6]Four possible teams
[4]reverse="true" switches the colors

[6]numAsWord works as a single tag and does anything (maybe always "number here")
[4]it works for some numbers
[6]it works for 0 to 99
[4]it Uses a StringBuilder to make the word   <--- the only place I mention this

 

--- Notes:

o For the numbers, I used several arrays:
 My arrays were 0-9 as words, the tens place words (ten, twenty ... ) and the
   special teens words (eleven ... )
 Getting fancy by auto-adding "teen" to "fif" and "six" ... seems like too much.
 
 I used a big nested-if:
   0-9 is a thing, 11-19 are special "teens" words, otherwise it's:
     "tens string" "ones string" (like "forty" plus "seven")
   And of course, a one's place of 0 is a special case (so we don't print sixty-zero)

 
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
CMPTR
CMPTR
Computer Science
ISBN:
9781337681872
Author:
PINARD
Publisher:
Cengage