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.
<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
<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.
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
A day job? In an office? My worst nightmare! Comfort me tiny ad!