This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Assume that the request for this page contains a parameter mystring=hello.
In the jdiscuss exam, the answer is 'It will print "" '. How is this possible?
The answer is right. The useBean will create the bean mystring. As the String have a no-arg public constructor, there is no problem with this statement. The mystring will point to empty string.
The setProperty is using property="*" to set the properties of mystring. It will not found any property from the request parameters to set in the string object. So, it will not set anything in the mystring string object.
The third expression will print the string to the browser. The String mystring have value "" (Empty string) as it is created as new String(). So it will pring nothing.