Thanks Kapil...dont know what i was thinking when i posted the question...
one more question ....
i am trying to use setProperty , below is my jsp :
result.jsp:
<html><body>
<jsp:useBean id="person" class="com.example.Person" scope="page" >
Person created by: <jsp:setProperty name="person" property="name" value="Fred" />
</jsp:useBean>
</body></html>
and PersonServlet.java
public class PersonServlet extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException{
doPost(request,response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException{
Person p = new Person();
//p.setName("Evan");
//request.setAttribute("person",p);
RequestDispatcher view = request.getRequestDispatcher("result.jsp");
view.forward(request,response);
}
}
It says "the property value will be set only if a new bean is created. If an existing bean with that scope and id are found, the body of the tag will never run, so property won't be reset from your JSP code "
So i commented
//p.setName("Evan");
//request.setAttribute("person",p);
still i do not get Fred in the output. Thanks