title: how to get return value from java class to servlet?
body: <p>hi can i know how to pass return value from normal java class to servlet then display it using jsp? i tried but only got null value. </p>
  
  <p>Result.java</p>
  
  <pre><code>package langID; 
  
  public class Result {
  
  public String Show()
  {
  
      return "result";
  
  }
  }
  </code></pre>
  
  <p>Formhandler.java (servlet)</p>
  
  <pre><code>protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      // TODO Auto-generated method stub
  
  RequestDispatcher rd = request.getRequestDispatcher("comment.jsp");    
  Result demo = new Result();
  String s = demo.Show();
  request.setAttribute("s", s);  
  rd.forward(request, response);
  
  }
  </code></pre>
  
  <p>comment.jsp</p>
  
  <pre><code>&lt;%String name = (String)request.getAttribute("s"); %&gt;
                      &lt;%= s%&gt;
  </code></pre>