The objective of this workshop is use a declaration to define a method which will reverse the characters of a given string.
This workshop should take no longer than 30 minutes.
The following demonstrates the objective of this workshop.
<html> <head> <title>Declarations</title> </head> <body> <p>The phrase,</p> <p><i></i></p> <p>Reads like this in reverse,</p> <p><i></i></p> </body> </html>
String variable, note this should be entered as a single line,
String strQuote = "If you can keep your head when
all about you, Are losing theirs
and blaming it on you;";
reverseString() which
takes a String as a parameter and returns a String.String in reverese. You'll
probably want to make use of the length() and substring() methods of the string
class. Check the Java API for definitions of these methods.String reversed in the second set of italics, something
like,
<P>Reads like this in reverse,</P> <P><I> <%= reverseString(strQuote) %> </I></P>
If you couldn't get your solution to work then click the icon to display the source code.
Other than Java coding errors there's not much that can go wrong with declarations. An obvious error is forgetting to put the ! in the JSP tags. Go back to your JSP, take this out and see what error you get.
The next topic looks at JSP Directives.