aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes jsp:getProperty Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "jsp:getProperty" Watch "jsp:getProperty" New topic
Author

jsp:getProperty

mysha ahamed
Greenhorn

Joined: Aug 03, 2005
Posts: 22
Hi
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>
<br><br><br>
<input type="submit" />
</form>
________________________________________
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();
per.setName(nameVal);
per.setCity(cityVal);
req.setAttribute("myper",per); //line1
RequestDispatcher rd=req.getRequestDispatcher("myUseBean.jsp");
rd.forward(req,res);

}

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

//line2
<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?

Thnx
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: jsp:getProperty