wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Problem with the <c:out> that provides a default attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Problem with the <c:out> that provides a default attribute" Watch "Problem with the <c:out> that provides a default attribute" New topic
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
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1638
    
  23

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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with the <c:out> that provides a default attribute
 
Similar Threads
Using JSTL Data Displayed In Browser Is Getting Fixed To 24576 Bytes(24 KB)
javascript error: object expected
Object does not support property error!
<jsp:forward ...> not acting the way it should.
JSP attendance management project error