• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Problem with the <c:out> that provides a default attribute

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Creator of Enthuware JWS+ V6
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Oprah Thaddeus
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Oprah Thaddeus
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic