title: Convert java bean to json string using Struts
body: <p>I want to use struts to render content in a JSP page.</p>
  
  <p>I have the Java Bean class implementing <code>Serializable</code>:</p>
  
  <pre><code>public class MyPOJO implements Serializable {
      String name;
      int value;
      // A lot of other members, but all String or int
      // Getters and setters
  }
  </code></pre>
  
  <p>And my form class with a list of MyPOJO:</p>
  
  <pre><code>public class MyForm extends ActionForm {
      private List&lt;MyPOJO&gt; results = new ArrayList&lt;MyPOJO&gt;();
      // Getter and setter
  }
  </code></pre>
  
  <p>And a class inheriting DispatchAction to pass a MyForm object onto the page.</p>
  
  <p>On the jsp page I use:</p>
  
  <pre><code>&lt;logic:notEmpty name="myForm" property="results"&gt;
  var jsonData = ${myForm.results};
  &lt;/logic:notEmpty&gt;
  </code></pre>
  
  <p>The final result in the generated jsp file is a list of MyPOJO objects:</p>
  
  <blockquote>
    <p>var jsonData = [com.package.MyPOJO@174aee5, ...]</p>
  </blockquote>
  
  <p>I'd like to know, without overriding <code>toString()</code> method inside MyPOJO class is there any other way to directly convert it to json String? I've also created a rest service returning a list of MyPOJO, without the <code>toString()</code> method, it can already show the JSON string, I'd like to know why it doesn't work for the JSP form bean?</p>