U need to add the userbean to the session scope within the servlet.
This line:
<jsp:useBean id="user" class="UserBean" scope="session" />
is looking for userbean in the session scope.. since ur servlet doesnt put
it there.. it decides to create a new one.
I use this if i need a bean in a page that will set up a bean for the
servlet.
U should use:
UserBean userbean = new UserBean();
userbean.setSomething("something");
request.getSession().setAttribute( "user", userbean );
Common mistake.. i do it all the time.
-Tim
-----Original Message-----
From: Mark Galbreath [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 28, 2001 11:42 AM
To: [EMAIL PROTECTED]
Subject: Last Question Today
I promise!
I've never done this before and I can find no help in any of the Sun
tutorials. I'm trying to set the properties in a Bean with a servlet and
get those properties with a JSP. I believe I am doing everything correctly,
but I'm getting NULLs (no NullPointerExceptions, I'm getting "NULL" as HTML)
on the JSP as returns for the Bean's getters.
The Bean DECLARES the properties:
public class UserBean implements serializable {
private String something;
public String getSomething() {
return something;
}
public void setSomething( String thing) {
this.something = thing;
}
...
}
The servlet SETS the properties:
...
UserBean userbean = new UserBean();
userbean.setSomething( String string);
...
And the JSP GETS the properties:
...
<jsp:useBean id="user" class="UserBean" scope="session" />
<jsp:getProperty name="user" property="something" />
...
Pretty straightforward, right? Why am I getting "NULL" in the JSP instead
of the string set by the servlet? Am I missing something in the JSP
getProperty? Is the servlet setting the properties correctly? One
additional point, the code helper (class/method dot popups) in Forte does
not display any of UserBean's methods when I type "userbean." (userbean +
period).
Thanks,
Mark
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html