tags:

views:

33

answers:

2

I have set a property in Action class as follows

public class HelloWorld{
  public String execute() { ANNOTATION #1
  setCustomGreeting( GREETING + getName() );
  return "SUCCESS"; 
  }
  private String customGreeting;
  public String getCustomGreeting()
  {
    return customGreeting;
  }
  public void setCustomGreeting( String customGreeting ){
  this.customGreeting = customGreeting;
}
}

And i m trying to render it on jsp as follows

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>HelloWorld</title>
</head>
<body>
<h3>Custom Greeting Page</h3>
<h4><s:property value="customGreeting"/></h4> 
</body>
</html>

But it's printing nothing on the jsp, please help me?

A: 

Your Code looks fine?

Do you call the JSP directly?

Is your Action mapped in the struts.xml?

jogep
yes my action is mapped in struts.xml, other contents on the target jsp are being displayed properly, but the problem is only with <h4><s:property value="customGreeting"/></h4>
Jitendra
Did you extend com.opensymphony.xwork2.ActionSupport?
Trick
A: 

Debugging suggestions:

  • Put breakpoints (or trace statements, or whatever) in the methods to confirm whether or not they are called.
  • Place an <s:debug/> tag on the page.
  • If that doesn't give any hints, then enable more detailed logging (how to do this will depend on what logging framework is being used), specifically for OGNL.
Todd Owen