• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp:getProperty  RSS feed

Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have dbt in action tags..I have an html whose parameter values iam setting in jave bean in a servlet code.Iam retrieving the bean values again
in a jsp..
<form action="PersonServleturi" method="post">
<b>Enter ur name : <input type="text" name="name" /><br>
<b>Enter ur city : <input type="text" name="city" /><br>
<input type="submit" />
public class PersonServlet extends HttpServlet
public void service(HttpServletRequest req,HttpServletResponse res)
String nameVal =req.getParameter("name");
String cityVal =req.getParameter("city");
PersonBean per=new PersonBean();
req.setAttribute("myper",per); //line1
RequestDispatcher rd=req.getRequestDispatcher("myUseBean.jsp");


<%@page import="java.util.*,myuseBean.*" %>

<jsp:useBean id="myper" class="myuseBean.PersonBean" scope="session"/> <b>Ur name is: :
<jsp:getProperty name="myper" property="name"/>
<br>Ur city is :
<jsp:getProperty name="myper" property="city"/>
In line 1 above iam storing the attribute "myper" in request scope..
In line 2 iam trying to retrive the value of same bean object "myper" from a session scope..I thought <jsp:getProperty >on this object shuld return null.But its returning the values of the object tht I stored in line 1..why is it so?Can anyone pls explain this?

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!