title: getting json data null in struts2 action class
body: <p>//I am developing a web application using struts2 framework. I am new to json and trying to send  json data via ajax to action class.But getting null values in action class//</p>
  
  <p>Step1:
  //Implemented json3.min.js//</p>
  
  <pre><code>var iprodReportsViewReportSqlQueryDetails={
      rtemplateSqlquery : sqlQuery,
      jdbcDriverUrl : jdbcDriverUrlG,
      jdbcDriverClassname : jdbcDriverClassnameG,
      databaseInstanceName : databaseInstanceNameG,
      databaseServerName : databaseServerUsernameG,
      databaseServerPassword : databaseServerPasswordG,
  };
  
  $.ajax({
      type : "POST",
      url : 'validateBuiltSqlQueryAction',
      cache : false,
      async : false,
      dataType : 'json',
      contentType:"application/json;charset=utf-8",
      data :  JSON.stringify(iprodReportsViewReportSqlQueryDetails),
      success : function(data) {
              // we have the response
              alert("successs");
  
      },
      error : function(e) {
              alert("error occured");
      }
  });
  
  
  /*********This is the action class where the json data is to be received***********/
  /* We have used gson for deserialization. */
  public class IprodReportsSqlQueryMasterAction extends ActionSupport {
  
      protected String rtemplateSqlquery;
      protected String jdbcDriverClassname;
      protected String jdbcDriverUrl;
      protected String databaseInstanceName;
      protected String databaseServerName;
      protected String databaseServerPassword;
      protected String data;
      public String validateSqlQuery() {
              Gson gs=new Gson();
              System.out.println("Data received:"+ getData());
  
  IprodReportsViewReportSqlQueryDetails iprodReportsViewReportSqlQueryDetailsObject=gs.fromJson(data, IprodReportsViewReportSqlQueryDetails.class);
               System.out.println(iprodReportsViewReportSqlQueryDetailsObject.getRtemplateSqlquery());
               System.out.println(iprodReportsViewReportSqlQueryDetailsObject.getJdbcDriverClassname());
               System.out.println(iprodReportsViewReportSqlQueryDetailsObject.getJdbcDriverUrl());
               System.out.println(iprodReportsViewReportSqlQueryDetailsObject.getDatabaseInstanceName());
               System.out.println(iprodReportsViewReportSqlQueryDetailsObject.getDatabaseServerName());
               System.out.println(iprodReportsViewReportSqlQueryDetailsObject.getDatabaseServerPassword());
  
          return SUCCESS;
          }
  
  
      public String getRtemplateSqlquery()
      {
          return rtemplateSqlquery;
      }
  
          public void setRtemplateSqlquery(String rtemplateSqlquery)
      {
          this.rtemplateSqlquery = rtemplateSqlquery;
      }
  
  
      public String getJdbcDriverClassname()
      {
          return jdbcDriverClassname;
      }
  
  
      public void setJdbcDriverClassname(String jdbcDriverClassname)
      {
          this.jdbcDriverClassname = jdbcDriverClassname;
      }
  
  
      public String getJdbcDriverUrl()
      {
          return jdbcDriverUrl;
      }
  
  
      public void setJdbcDriverUrl(String jdbcDriverUrl)
      {
          this.jdbcDriverUrl = jdbcDriverUrl;
      }
  
  
      public String getDatabaseInstanceName()
      {
          return databaseInstanceName;
      }
  
  
      public void setDatabaseInstanceName(String databaseInstanceName)
      {
          this.databaseInstanceName = databaseInstanceName;
      }
  
  
      public String getDatabaseServerName()
      {
          return databaseServerName;
      }
  
  
      public void setDatabaseServerName(String databaseServerName)
      {
          this.databaseServerName = databaseServerName;
      }
  
  
      public String getDatabaseServerPassword()
      {
          return databaseServerPassword;
      }
  
  
      public void setDatabaseServerPassword(String databaseServerPassword)
      {
          this.databaseServerPassword = databaseServerPassword;
      }
  
      public String getData() {
          return data;
      }
  
      public void setData(String data) {
          this.data = data;
      }
  
  }
  
  /*****struts.xml***************//
   &lt;package name="json-default-package" extends="json-default"&gt;
          &lt;result-types&gt;
              &lt;result-type name="json" class="org.apache.struts2.json.JSONResult"/&gt;
          &lt;/result-types&gt;
          &lt;interceptors&gt;
              &lt;interceptor name="json" class="org.apache.struts2.json.JSONInterceptor"/&gt;
          &lt;/interceptors&gt;
  
  &lt;/package&gt;
  
                 &lt;package extends="json-default-package" name="validateSqlQuery" namespace="/"&gt;
              &lt;action class="com.id4.iprod.reports.IprodReportsSqlQueryMasterAction" method="validateSqlQuery" name="validateBuiltSqlQueryAction"&gt;
  
                       &lt;interceptor-ref name="json"&gt; 
                        &lt;param name="contentType"&gt;application/JSON&lt;/param&gt;
                        &lt;/interceptor-ref&gt;
                        &lt;result name="success" type="json"&gt;&lt;/result&gt;
                    &lt;/action&gt;                                                                                
  
  
      &lt;/package&gt;
  
     /***********************************************/
  /****bean object class  IprodReportsViewReportSqlQueryDetails***** //
  
  public class IprodReportsViewReportSqlQueryDetails implements Serializable
  {
  
      protected String rtemplateSqlquery;
  
          protected String jdbcDriverClassname;
  
          protected String jdbcDriverUrl;
  
          protected String databaseInstanceName;
  
          protected String databaseServerName;
  
  
      protected String databaseServerPassword;
  
  
      public IprodReportsViewReportSqlQueryDetails()
      {
      }
  
  
      public String getRtemplateSqlquery()
      {
          return rtemplateSqlquery;
      }
  
  
      public void setRtemplateSqlquery(String rtemplateSqlquery)
      {
          this.rtemplateSqlquery = rtemplateSqlquery;
      }
  
          public String getJdbcDriverClassname()
      {
          return jdbcDriverClassname;
      }
  
      public void setJdbcDriverClassname(String jdbcDriverClassname)
      {
          this.jdbcDriverClassname = jdbcDriverClassname;
      }
  
          public String getJdbcDriverUrl()
      {
          return jdbcDriverUrl;
      }
  
  
      public void setJdbcDriverUrl(String jdbcDriverUrl)
      {
          this.jdbcDriverUrl = jdbcDriverUrl;
      }
  
      public String getDatabaseInstanceName()
      {
          return databaseInstanceName;
      }
  
          public void setDatabaseInstanceName(String databaseInstanceName)
      {
          this.databaseInstanceName = databaseInstanceName;
      }
  
  
      public String getDatabaseServerName()
      {
          return databaseServerName;
      }
  
  
      public void setDatabaseServerName(String databaseServerName)
      {
          this.databaseServerName = databaseServerName;
      }
  
  
      public String getDatabaseServerPassword()
      {
          return databaseServerPassword;
      }
  
  
      public void setDatabaseServerPassword(String databaseServerPassword)
      {
          this.databaseServerPassword = databaseServerPassword;
      }
  
          public boolean equals(Object _other)
      {
          if (_other == null) {
              return false;
          }
  
          if (_other == this) {
              return true;
          }
  
          if (!(_other instanceof IprodReportsViewReportSqlQueryDetails)) {
              return false;
          }
  
          final IprodReportsViewReportSqlQueryDetails _cast = (IprodReportsViewReportSqlQueryDetails) _other;
          if (rtemplateSqlquery == null ? _cast.rtemplateSqlquery != rtemplateSqlquery : !rtemplateSqlquery.equals( _cast.rtemplateSqlquery )) {
              return false;
          }
  
          if (jdbcDriverClassname == null ? _cast.jdbcDriverClassname != jdbcDriverClassname : !jdbcDriverClassname.equals( _cast.jdbcDriverClassname )) {
              return false;
          }
  
          if (jdbcDriverUrl == null ? _cast.jdbcDriverUrl != jdbcDriverUrl : !jdbcDriverUrl.equals( _cast.jdbcDriverUrl )) {
              return false;
          }
  
          if (databaseInstanceName == null ? _cast.databaseInstanceName != databaseInstanceName : !databaseInstanceName.equals( _cast.databaseInstanceName )) {
              return false;
          }
  
          if (databaseServerName == null ? _cast.databaseServerName != databaseServerName : !databaseServerName.equals( _cast.databaseServerName )) {
              return false;
          }
  
          if (databaseServerPassword == null ? _cast.databaseServerPassword != databaseServerPassword : !databaseServerPassword.equals( _cast.databaseServerPassword )) {
              return false;
          }
  
          return true;
      }
  
          public int hashCode()
      {
          int _hashCode = 0;
          if (rtemplateSqlquery != null) {
              _hashCode = 29 * _hashCode + rtemplateSqlquery.hashCode();
          }
  
          if (jdbcDriverClassname != null) {
              _hashCode = 29 * _hashCode + jdbcDriverClassname.hashCode();
          }
  
          if (jdbcDriverUrl != null) {
              _hashCode = 29 * _hashCode + jdbcDriverUrl.hashCode();
          }
  
          if (databaseInstanceName != null) {
              _hashCode = 29 * _hashCode + databaseInstanceName.hashCode();
          }
  
          if (databaseServerName != null) {
              _hashCode = 29 * _hashCode + databaseServerName.hashCode();
          }
  
          if (databaseServerPassword != null) {
              _hashCode = 29 * _hashCode + databaseServerPassword.hashCode();
          }
  
          return _hashCode;
      }
  
  
      public String toString()
      {
          StringBuffer ret = new StringBuffer();
          ret.append( "com.id4.iprod.reports.dto.IprodReportsViewReportSqlQueryDetails: " );
          ret.append( "rtemplateSqlquery=" + rtemplateSqlquery );
          ret.append( ", jdbcDriverClassname=" + jdbcDriverClassname );
          ret.append( ", jdbcDriverUrl=" + jdbcDriverUrl );
          ret.append( ", databaseInstanceName=" + databaseInstanceName );
          ret.append( ", databaseServerName=" + databaseServerName );
          ret.append( ", databaseServerPassword=" + databaseServerPassword );
          return ret.toString();
      }
  
  }
  </code></pre>