| Author |
Problem with the <c:out> that provides a default attribute
|
Swagato Bhatta
Ranch Hand
Joined: Nov 08, 2008
Posts: 72
|
|
I am just trying to print a default value when the user does not input any values in the form (of page index.jsp).
In the Bert's book of 2nd edition, it states that
This value is output if the value attribute evaluates to null. And, the above should render as
Here is the jsp page that does the c : out testing with default.
Here is the index.jsp page
I do not get the default value printed when there is no input in the form. I expected the default guest value should get printed!
|
Working on my SCWCD so I can be a J2EE consultant earning millions of dollars and showing everyone I can
|
 |
Frits Walraven
Rancher
Joined: Apr 07, 2010
Posts: 1043
|
|
Hi Swagato,
Because you are submitting a parameter with the name "name" it will handle it as an empty String, and therefore outputing an empty String instead of your default value. If you remove <input type="text" name="name"> from your jsp it should work as you had expected.
Regards,
Frits
|
 |
Swagato Bhatta
Ranch Hand
Joined: Nov 08, 2008
Posts: 72
|
|
Frits Walraven wrote:Hi Swagato,
Because you are submitting a parameter with the name "name" it will handle it as an empty String, and therefore outputing an empty String instead of your default value. If you remove <input type="text" name="name"> from your jsp it should work as you had expected.
Regards,
Frits
So, not providing any data in the form basically means an "empty string". Whereas no input type means null? AM i right?
|
 |
Swagato Bhatta
Ranch Hand
Joined: Nov 08, 2008
Posts: 72
|
|
Frits Walraven wrote:Hi Swagato,
Because you are submitting a parameter with the name "name" it will handle it as an empty String, and therefore outputing an empty String instead of your default value. If you remove <input type="text" name="name"> from your jsp it should work as you had expected.
Regards,
Frits
Thanks
|
 |
 |
|
|
subject: Problem with the <c:out> that provides a default attribute
|
|
|