Skip to Content
Former Member
Nov 19, 2004 at 04:21 PM

a simple Bean that doesnt work


hye all,

i have a simple program that doesnt work. I am a beginner in Portal Programming and I wanted to test a bean which exchanges data between a JSPDynPage and a JSP. I want this bean to simple display a String, set by the user in the method doInitialization.

The bean class is <b>UserInputBean</b> with the following code:

package beans;

public class UserInputBean {

public String name;

public String getName() {

return name;


public void setName(String name) { = name;



In the Java class I have the following code in <b>doInitialization()</b> method :

IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();

IPortalComponentContext myContext = request.getComponentContext();

// new bean object

UserInputBean myNameContainer = new UserInputBean();

myNameContainer.setName("unknown user");

myContext.putValue("myexb", myNameContainer);

and in my jsp i have the following lines:

<%@taglib uri="tagLib" prefix="hbj"%>

<jsp:useBean id="myexb" scope="application" class="beans.UserInputBean"/>

<hbj:content id="myContext">

<hbj:page title="PageTitle">

<hbj:form id="myForm" >



design="HEADER1" >

<%welcome_message.setText("My name is "+myexb.getName()); %>





When starting the component, the display should be "My name is unknown user", but instead of that I get "My name is null", so the bean doesnt set its data ?

Can somebody tell me why this application doesnt work? i have spend all my day trying to find out..