Custom tags may also define scripting variables to use within the JSP page. Scripting variables are used in processing JSP page content, just as variables would be in any Java implementation. The scripting variables can be referenced the same as JavaBeans: by using the getAttribute() and setAttribute() methods. To create a scripting variable, implement a class that extends the TagExtraInfo class as shown in the GreetingsTei.java file in Listing 18.6.
Next implement initialization and variable modification logic within the parent tag handler class, as shown in Listing 18.7, GreetingsBidder.java.
Jar the TLD and subject classes (or add new classes and an updated TLD to an existing tag library JAR file—you can add new tags to existing tag libraries). Register the resultant JAR (if not previously registered) within the target application's web.xml as discussed earlier. Finally, you need only code a JSP that uses the scripting variables as shown in Listing 18.8, GreetingsBidder.jsp.
The browser view produced by GreetingsBidder.jsp is presented in Figure 18.5.