HI I am not using any MVC .. But I would like to get the same functionality in my JSP Servlets application.
I have jsp having some text fields of date, string, number..etc.. I have created a form bean class with the names of text fields in my jsp with getters and setters like below..
JSP (Edited)
<form name="myForm" action="myAction" method="post">
<jsp:useBean id="jspBean" class="com.package.my.BeanClass" scope="request" />
<jsp:setProperty prperty="*" name="jspBean" />
//Below some text fields and date fileds
<table>
<tr>
<td>
UserName :
</td>
<td>
<input type="text" value="${myBean.userName}" name="userName"/>
</td>
</tr>
<td>
PassWord :
</td>
<td>
<input type="text" value="${myBean.passWord}" name="passWord"/>
</td>
</tr>
<td>
Date :
</td>
<td>
<input type="text" value="${myBean.date}" name="date"/>
// This text field is with JQUery Date picker
</td>
</tr>
<tr>
<td>
<input type="submit" value="login" />
</td
</tr>
</table>
</form>
IN My servlet
// I Can get those text fields as Parameters i.e
req.getParameter("userName")
//And I cant get that bean Object `jspBean`
// I am trying to get that as below
sysout(req.getAttribute("jspBean"));//It prints null
// So I create a plain bean object and I am setting the data here
MyBean bean = new MyBean();
// bean.setUserName();
// I am setting all these fields whaterver needed
req.setAttribute("myBean",bean);
problem
1) I can get the bean object and its data from Servlet
to JSP
usinf EL
I am able to do.. What I want is I want send form data(all fields) as BeanObject instead of Parameters.. That I am not able to acheive,
How to achieve this.. Please help
Thanks in advance./