• Post Reply Bookmark Topic Watch Topic
  • New Topic

Extending bean's properties

 
Agnit Chatterjee
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
suppose we write a jsp file and obtain a property called name from the user input like say:

<input type="text" name="name" size="25" />

in abc.jsp

how can we use this name property in another jsp file
 
Stefan Evans
Bartender
Posts: 1822
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well it will be available as a request parameter called "name" when the form it is on is submitted.

So in java code you can get hold of it with request.getParameter("name");

in EL you can use ${param.name}

If you want to use "old-school" jsp, it would be usable with a <jsp:setProperty id="myBean" property="name"> tag to set the property of a bean which has appropriate get/set methods (getName(), setName())

All different ways of accessing the same value.

If you want it to stick around longer than one request, you would have to store the value into a session attribute.

 
Agnit Chatterjee
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we use this name property in another jsp file say efgh just by using <jsp:setProperty id="myBean" property="name"> or using the request.getParameter("name");


How will the jsp recognize in which jsp file the property name was initially used for???
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!