This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes  jsp:useBean doubt.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark " jsp:useBean doubt.." Watch " jsp:useBean doubt.." New topic
Author

jsp:useBean doubt..

Narasimha Rao B.
Ranch Hand

Joined: Aug 26, 2002
Posts: 205
Hi,

What is the output of from the below JSP code?
<jsp:useBean id="name" class="java.lang.String" />
<%= name %>


I think answer will be nothing (empty string), because it is equivalent to --
String name = new String();
System.out.println(name);
name is not assigned to any string value, hence its value will be empty string...

Thanks,


Narasimha
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2053
Yes,

if there is no String named 'name' in the context.

Otherwise, that will be the value.

As you know, useBean is popularly used after the object has been created somewhere already; like from a servlet that called the jsp.
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2053
it is equivalent to --
String name = new String();


It is not equivalent.

It is more like the following pseudocode:

If name exists in the context
return that name instance
else
String name = new String();
end-if
Jaime Yong
Greenhorn

Joined: Oct 05, 2005
Posts: 20
The output will be ""
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp:useBean doubt..