File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes problem with Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "problem with "jsp:useBean"  tag" Watch "problem with "jsp:useBean"  tag" New topic
Author

problem with "jsp:useBean" tag

J Lalit
Greenhorn

Joined: May 19, 2008
Posts: 15
Hi,

i have two jsp,first is the one from where i am submitting data & second where i am showing data using <jsp:useBean> tag but getting null on second jsp.My jsps are as below.

----------index.jsp-----------

<body>
<form name="myForm" method="post" action="showData.jsp">
<jsp:useBean id="show" class="com.test.ShowBean" scope="session"/>
<jsp:setProperty name="show" property="*"/>
<table>
<tr>
<td>
Enter Your Name :
<input type="text" name="name"/>
</td>
</tr>
<tr>
<td>
Enter Your Mobile :
<input type="text" name="mobile"/>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Submit"/>
</td>
</tr>
</table>
</form>
</body>

From here i am submitting request to showData.jsp which is as

-----------showData.jsp-----------

<body>
<jsp:useBean id="show" class="com.test.ShowBean" scope="session"/>
Name is : <jsp:getProperty name="show" property="name"/><br>
Mobile is : <jsp:getProperty name="show" property="mobile"/><br>
</body>

But i am getting values of name & mobile as null.

Can anyone tell me where it is going wrong.

Also can i use <jsp:useBean> to submit data to a servlet & show data there as also in that case i am getting null values.

Thanks in Advance.


Thanks & Regards
J Lalit.
tong yuxin
Greenhorn

Joined: Jul 21, 2008
Posts: 19
hi, i think (not sure) ths index.jsp has some problem

<jsp:setProperty name="show" property="*"/>
==
<jsp:setProperty name="show" property="name" param="name">
<jsp:setProperty name="show" property="moblie" param="mobile">

So, before index.jsp sent the request, it cannot get the paramvalue at that time.


SJCP 98%
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by tong yuxin:
So, before index.jsp sent the request, it cannot get the paramvalue at that time.


Exactly...

----------------------------------------------------------
i think (not sure) ths index.jsp has some problem

<jsp:setProperty name="show" property="*"/>
==
<jsp:setProperty name="show" property="name" param="name">
<jsp:setProperty name="show" property="moblie" param="mobile">
-------------------------------------------------------

Not a problem if form field name and setter method name(bean method) same
Marimuthu Madasamy
Ranch Hand

Joined: Jun 07, 2007
Posts: 72

There are two request objects involved. First one is to render index.jsp and the second one is to render showData.jsp (after you submit the form in index.jsp). your jsp:setProperty in index.jsp retrieves the parameters (actually there is none) from the first request and sets the properties. When you submit the form, now the new request (to showData.jsp) with the submitted data is sent but you didnt use the jsp:setProperty in showData.jsp. so

have this line in showData.jsp after jsp:useBean,


- Marimuthu Madasamy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with "jsp:useBean" tag