File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark " jsp:useBean doubt.." Watch " jsp:useBean doubt.." New topic

jsp:useBean doubt..

Narasimha Rao B.
Ranch Hand

Joined: Aug 26, 2002
Posts: 205

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();
name is not assigned to any string value, hence its value will be empty string...


Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2049

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: 2049
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
String name = new String();
Jaime Yong

Joined: Oct 05, 2005
Posts: 20
The output will be ""
I agree. Here's the link:
subject: jsp:useBean doubt..
Similar Threads
jsp:setProperty body-content
usebean doubt
jsp:getProperty calling bean from specific scope
Request time attributes
few more doubts