• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

bean vs jsp:useBean problem

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have a little problem that I'd like to resolve just for my own gratification.

A have a simple class as follows:

package beans;

public class hellobean
{
private String name = "world";

public void setName (String name)
{
this.name = name;
}
public String getName()
{
return name;
}
}

As you can see it's a no big deal class. When I call the class with the following JSP page everything works just fine.

<html>
<jsp:useBean id="hello" class="beans.hellobean" />
<jsp:setProperty name="hello" property="name" value="dave" />
<jsp:getProperty name="hello" property="name" />
</html>

But the following page:

<%@ page language="java" import="beans.hellobean"%>

<bean name="hello" type="hellobean" introspect="yes" create="yes" scope="request"></bean>
<html>
<%=hello.getName()%> //line 5
</html>

gives me a complie error on line 5, "hello cannot be resolved", which to me implies that the bean has not been created. Yet if I remove line 5 the page compiles without any issues. Can anyone see something that I don't see? This is not critical... I just hate it when something doesn't work and I can't see why.

Thanks
Dave B.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

<bean name="hello" type="hellobean" introspect="yes" create="yes" scope="request"></bean>



What is a <bean> tag?
 
Dave Berkheimer
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The <BEAN> tag can be seen here about one quarter of the way down the page:

http://www-306.ibm.com/software/webservers/appserv/doc/guide/asgdwp.html#HDRSAMPJSP

Dave
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That page is so old I think it might have been originally written using a stone slab and chisel.

Get yourself a copy of the JSP 2.0 Specification -- links available in JSP FAQ.
 
Dave Berkheimer
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, it appears that the JSP specification no longer supports the <bean> tag. Just curious though, the bean tag allowed for introspection, a process that allowed the bean to automatically detect and then use applicable incoming parameters through the request object. Is there a comparable method that anyone knows of in the new JSP specifications? Or is it necessary now to always explicitly pass the parameters to the bean? For what it's worth, introspection seemed like a real handy-dandy thing.

Dave
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The bean tag was the beta version of <jsp:useBean> back before JSP 1.0. All this dust is making me sneeze...

Check out the permutations of <jsp:setProperty> for the functionality you seek.
 
reply
    Bookmark Topic Watch Topic
  • New Topic