Forums Register Login

JSP / Bean prob.

+Pie Number of slices to send: Send
Hi,
Iam using JRun 3.0 on IIS4.0(sp2), I developed a application using JSP/Bean combination, in JSP, Iam just using useBean to instantiate bean for first time and setting all the properties using '*' and Iam using that bean ID in servlet by just retrieving thru session which already set in JSP.
But when I tried to retrieve all the parameter information, its giving nothing. I guess the bean properties has not been set.
What could be the problem. Is it problem with getter/setter's?
I verified lettering.I use the following syntax
<jsp:useBean id="userProfile" class="UserProfileBean" scope="session">
<jsp:setProperty name="userProfile" property="*"/>
</jsp:useBean>
In servlet, retrieving bean thru session, but Iam getting objectId but property values, which r blank. what could be the reason.
Thx.
+Pie Number of slices to send: Send
Verify that your JavaBean methods satisfy the naming conventions (public X getMyProperty(), public void setMyProperty(X myProperty)). Your request parameter names should match the property names, including capitalisation ("myProperty"). The first letter must be lowercase in many implementations. The property's data type should basically be a primitive type or a String.
- Peter
+Pie Number of slices to send: Send
1) check if the names of variables match between JSP and your bean class.
2) use the following syntax:
<%@ page language="java" %>
<jsp:useBean id="objectID" scope="session" class="classID" />
<jsp:setProperty name="objectID" property="*" />
Please note you do not need:
</jsp:useBean>
It will work reliably.
hope solve your problem.
Ruilin
+Pie Number of slices to send: Send
 

Originally posted by ruilin yang:
[...]Please note you do not need:
</jsp:useBean>


Good point, Ruilin. With Anil's original code, the properties will only be set when the bean is first instantiated. This can be a very sensible thing to do, but Anil may not have intended this.
- Peter
+Pie Number of slices to send: Send
Thx for ur responses. I have tried using the above code, but void. I dont understand why properties aren't setting. Even I put debugging statements in getters/setters but none is being printed on console. What could be the reason.
Thx.
+Pie Number of slices to send: Send
Any solution....waiting for.
Thx.
+Pie Number of slices to send: Send
To reiterate Peter's point, are you sure that you have exact matches between your request parameter names and the JavaBean variable names, and the appropriate set/get methods? Maybe you can post more of your code. For example, if your request came from a page that had:
<input name="fooBar" value="" type="text">
then your JavaBean class should have something like:
public class UserProfileBean {
private String fooBar;
...
public String getFooBar() {
return fooBar;
}
public void setFooBar(String newBar) {
fooBar = newBar;
}
}
+Pie Number of slices to send: Send
Hi all,
I got it correct, the mistake is Iam setting bean using

before passing to the servlet, Iam setting all the properties , which are null. Those properties wont set even I fill up some text fields. So I need to check in Jsp like


[This message has been edited by Anil Vupputuri (edited June 14, 2001).]
Yup, yup, yup. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 928 times.
Similar Threads
beans
JSP, Beans and Session
JavaBean vs Post from a JSP
A JavaBean inside a JSP function
set all form parameters using jsp:setProperty
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 01:44:12.