• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jspSetProperty question

 
Jayashree Mohan
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP:

<html><body>
<jsp:useBean id = "bean" class="JBean" />
<jsp:setProperty name="bean" property="*">
Title : <%=bean.getTitle()%> <br>
Num : <jsp:getProperty name="bean" property="num" />
</body></html>

Bean class:

public class JBean
{
private String title = "JBean";
private int num;
public void setTitle(String t){ this.title = t; }
public String getTitle(){ return this.title; }
public void setNum(int n){ this.num = n; }
public int getNum(){ return this.num; }
}

THis is the URL
http://localhost:7001/test/First.jsp?title=Hello
The response printed was
Title : null
Num : 0

Shouldn't Title be printed Hello instead of null since property="*" ???

 
Sital Kotamraju
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<jsp:setProperty should be closed with a "/>" when there is no body.

<jsp:setProperty name="bean" property="*"/>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic