I am creating an instance of a bean and setting its value in 1 jsp page and after setting that bean in session attribute, I am trying to retrieve value of that bean using jsp action .
In the first jsp page, I am creating instance of Person using new keyword and then setting it as attribute in session.
On the second page, I am trying to print the name of the Person using jsp:getProperty tag.
The value comes null in the second page.
Code for first Page is as below
<%
String username=request.getParameter("username");
String password=request.getParameter("password");
if((username.equals("ravi") && password.equals("kumar")))
{
Person person = new Person();
person.setName(username);
session.setAttribute("username",person);
response.sendRedirect("Home.jsp");
}
else
response.sendRedirect("Error.jsp");
%>
Code for second page is as below :
<jsp:useBean id="person" class="com.ravi.entity.Person" scope="request"/>
Person created by Servlet <jsp:getProperty name="person" property="name"/>
Can any one help on this?