• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

problem with "jsp:useBean" tag  RSS feed

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 72
Java Monad Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!