File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 2061
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: 2061
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..