title: How private fields accessible on jsp page in struts 2.x?
body: <p>Hello every one I am working with struts 2.x and very new for this framework . I follow list of tutorials and steps and my application working properly but there is one thing which is not clear to me Like when I declare one private field in my action class and using struts tag that private field is accessible to the jsp page . So how it happen that is not understandable for me:</p>
  
  <p>struts.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE struts PUBLIC
     "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
     "http://struts.apache.org/dtds/struts-2.0.dtd"&gt;
  &lt;struts&gt;
  
  
      &lt;package name="default" namespace="/home" extends="struts-default"&gt;
  
          &lt;action name="message" class="com.csc.action.MessageAction"&gt;
              &lt;result name="hello"&gt;/hello.jsp&lt;/result&gt;
              &lt;result name="bye"&gt;/bye.jsp&lt;/result&gt;
          &lt;/action&gt;
          &lt;action name="add" class="com.csc.action.Mathaction"&gt;
              &lt;result name="success"&gt;/hello.jsp&lt;/result&gt;
              &lt;result name="fail"&gt;/bye.jsp&lt;/result&gt;
          &lt;/action&gt;
      &lt;/package&gt;
  
  
  
  &lt;/struts&gt;
  </code></pre>
  
  <p>MessageAction.java</p>
  
  <pre><code>package com.csc.action;
  
  import com.csc.service.BussniessServ;
  
  public class MessageAction {
  
      private String result;
  
      private String value;
  
      private String fstvalue;
  
       private String scndvalue;
      public String getFstvalue() {
          return fstvalue;
      }
  
      public void setFstvalue(String fstvalue) {
          this.fstvalue = fstvalue;
      }
  
      public String getScndvalue() {
          return scndvalue;
      }
  
      public void setScndvalue(String scndvalue) {
          this.scndvalue = scndvalue;
      }
  
  
      // method which get value from input parameter
      public String getValue() {
          return value;
      }
  
      // method which show the value of input parameter
      public void setValue(String value) {
          this.value = value;
      }
  
      // method which run as default and execute
      public String execute() {
  
          BussniessServ serv = new BussniessServ();
          setMessag(serv.Addition(fstvalue, scndvalue));
          return "hello";
      }
  
      // method to show message on jsp page
      public String getResult() {
  
          return result;
      }
  
      // method for save message
      public void setResult(String result) {
          this.result = result;
      }
  
  }
  </code></pre>
  
  <p>Result.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
     &lt;%@ taglib prefix="s" uri="/struts-tags"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;s:property value="result"/&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>