• Post Reply Bookmark Topic Watch Topic
  • New Topic

what would be output?  RSS feed

 
Ashish Kothari
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<jsp:useBean id="name" class="java.lang.String" />
<%= name %>
what would be output of the above code.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm guessing name will have "" the empty string.
 
Ashish Kothari
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah,thanks,it is true,but why not null ?
Ashish
 
Debashish Chakrabarty
Ranch Hand
Posts: 231
Firefox Browser Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not null? Put this in your JSP..
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66158
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but why not null ?

Because at the time that the scriptlet expression

is evaluated, the bean varaible name is not null!
The behavior of the useBean tag is such that if a bean of the specified name is not found in the specified scope (defaulted in your case), a bean of that type is created.
So, name is pointing to a newly-constructed empty string when evaluated.
hth,
bear
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!