Java Reference
In-Depth Information
The following step enters the code to use local variables in a JSP script.
To Use Local Variables in a JSP Script
1. Click the Save button. Enter lines 152 through 196 as shown in
Figure 12-73.
TextPad displays code for defining and using local variables in a JSP
(Figure 12-74). Each thread gets a unique copy of the local variables,
so the code is thread-safe.
beginning
scriptlet
tag
StringTokenizer
object
delimiter
characters
hasMoreTokens()
method
nextToken()
method
textarea
FIGURE 12-74
Optionally Creating HTML in a JSP
Recall that the main Web page displays the user maintenance section of the
GUI for administrative users only. Consequently, the JSP should not create the
HTML code for regular users. Figure 12-75 on the next page displays lines 197
through 239 of the code for mainForm.jsp. By using a JSP, the admin session
attribute for the current user can be examined to determine if the user is an
administrator (line 197) and, if so, output the necessary HTML code for the user
maintenance portion (lines 200 through 225). If the user is not an administrator,
this section of HTML code is not output to the resulting Web page. By creating
the HTML page dynamically, this decision is made during execution of the
application.
 
Search WWH ::




Custom Search