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)
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)

Step by step
Solved in 2 steps





