title: How to pass a value of a list to a hidden tag?
body: <p>I have the following code in my jsp:</p>
  
  <pre><code>&lt;c:forEach var="value" items="${MyList}" varStatus="loop"&gt;
    &lt;tr&gt;&lt;td&gt;&lt;div id="Name1"&gt;Here:${value.name}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;s:hidden id="Name" name="Name" value="%{value.name}"/&gt;
  </code></pre>
  
  <p>the html source is as following:</p>
  
  <pre><code>     &lt;tr&gt;&lt;td&gt;&lt;div id="Name1"&gt;Here:My name is X&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
       &lt;input type="hidden" name="Name" value="" id="Name"/&gt;
  </code></pre>
  
  <p>As demonstrated the div tag is showing the value.name correctly but the value attribute of hidden tag is empty. I could not find any solution because most of the solutions were not related to list.
  I changed it to <code>${value.name}</code> but ran into this error: "According to TLD or attribute directive in tag file, attribute value does not accept any expressions"</p>
  
  <p>My completed JSP is as following:</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
     "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;%@ taglib prefix="s" uri="/struts-tags" %&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt;  
  
  
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;Register&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="Search"&gt;
          &lt;label for="message"&gt;Travel details&lt;/label&gt;
      &lt;table border="1"&gt;
  
  
      &lt;s:form action="Search_Search" &gt;
  
  
        &lt;td&gt;
        &lt;s:textfield name="City" label="City" /&gt;&lt;/td&gt;
        &lt;td&gt;&lt;s:textfield name="HighRate" label="Budget" /&gt;&lt;/td&gt;
        &lt;td&gt;&lt;s:textfield name="Adults" label="Adults"/&gt;&lt;/td&gt;
        &lt;td&gt;&lt;s:textfield name="Childs" label="Child (less 15)"/&gt;&lt;/td&gt;
        &lt;td&gt;&lt;s:select label="Prefered hotel rate" name="rate" list="rate" value="no preference"/&gt;&lt;/td&gt; 
        &lt;td&gt;&lt;s:textfield name="Days" label="Days"/&gt;&lt;/td&gt;
        &lt;td&gt;&lt;s:radio label="Is the budget fixed" name="BdgFixed" list="BdgFixed"
              value="defaultBudget"/&gt;
        &lt;td&gt;&lt;s:submit/&gt;&lt;/td&gt;
  
        &lt;/s:form&gt;
  
  
      &lt;/table&gt;
  
  
      &lt;/div&gt;
  
      &lt;sx:div&gt;
                  &lt;table border="1"&gt;
                  &lt;tr&gt;
                  &lt;c:forEach var="Hotel" items="${HotelsList}" varStatus="loop"&gt;
                   &lt;c:set var="nameVar" scope="request" value="${Hotel.name}"/&gt;
                   &lt;c:if test="${not loop.first and loop.index % 3 == 0}"&gt;
                     &lt;/tr&gt;&lt;tr&gt;
                   &lt;/c:if&gt;
                  &lt;td&gt;
  
                    &lt;div id="HotelInfo"&gt;
  
  
  
           &lt;td&gt;
           &lt;s:form action="Search_AddHotel" &gt;
           &lt;tr&gt;&lt;td&gt;&lt;div id="image"&gt;&lt;img src=${Hotel.thumbNailUrl} alt="image"/&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
             &lt;s:textfield name="Name3" label="Budget" /&gt;  
           &lt;tr&gt;&lt;td&gt;&lt;div id="Name1"&gt;Here:&lt;c:out value="${nameVar}"/&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
           &lt;s:hidden id="Name" name="Name" value='${nameVar}'/&gt;
           &lt;s:label id="name2" name="name2" value="John"/&gt;
           &lt;tr&gt;&lt;td&gt;&lt;div id="Highest Rate:"&gt;Rate:${Hotel.highRate}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
           &lt;tr&gt;&lt;td&gt;&lt;div id="Address"&gt;Address:${Hotel.address}&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
           &lt;tr&gt;&lt;td&gt;
                        &lt;s:submit/&gt;
          &lt;/s:form&gt;
  
           &lt;/td&gt;&lt;/tr&gt;
            &lt;/td&gt;
  
                 &lt;/c:forEach&gt;
                      &lt;/tr&gt;
                  &lt;/table&gt;
     &lt;/sx:div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My completed Java class is as following:</p>
  
  <pre><code>package com.funontour.controller;
  
  import org.jdom.Document;
  import org.jdom.Element;
  import org.jdom.input.SAXBuilder;
  
  import com.funontour.common.Hotels;
  import com.funontour.model.DistanceModel;
  import com.funontour.model.SearchModel;
  
  import java.io.ByteArrayOutputStream;
  import java.io.Reader;
  import java.io.StringReader;
  
  import javax.xml.soap.*;
  import java.net.*;
  import java.util.*;
  
  public class SearchAction {
  
      private String Name;
      private String City;
      private String HighRate;
      private String Adults;
      private String Childs;
      private List HotelsList;
      private List&lt;String&gt; BdgFixed;
      private List&lt;String&gt; rate;
      private static final String Yes = "Yes";
      private static final String No = "No";
  
      public String execute() throws Exception {
          generateForm();
          // runClient(); //actual rate should be received
          // System.out.println("goes back to strut.xml");
          return "SUCCESS";
      }
      public String getName()
      {
          return Name;
      }
      public void setName(String name){
          this.Name = name;
      }
     public void AddHotel(){
         System.out.println("name is:"+Name);
         System.out.println("getName:" + getName());
         System.out.println("thisName" + this.Name);
  
     }
      public String Search() { // Country is set to AU
          System.out.println("In Search method of SearchAction");
          Showdetails();
          String result = SearchHotel();
  
          generateForm();  
          return result;
      }
  
      public void generateForm(){
  
          BdgFixed = new ArrayList&lt;String&gt;();
          BdgFixed.add(Yes);
          BdgFixed.add(No);
  
          rate = new ArrayList&lt;String&gt;();
          rate.add("1");
          rate.add("2");
          rate.add("3");
          rate.add("4");
          rate.add("5");
      }
  
      public void Showdetails(){
          System.out.println(this.City + " " + this.HighRate + " " + this.Adults + " " 
                  + this.Childs + " " + this.rate+ " " + this.BdgFixed);
      }
      public String SearchHotel(){
          HotelsList = new ArrayList();
          SearchModel searchModel = new SearchModel();
          List inputs = new ArrayList&lt;String&gt;();
  
  
          //If some of these are not entered should ask again
          // for multiple choices do not work if nothing has been selected
          if(!getCity().isEmpty())
          inputs.add(getCity());
          else
              inputs.add("London");
  
          if(!getHighRate().isEmpty())
          inputs.add(getHighRate());
          else
              inputs.add("0");
  
          if(!getAdults().isEmpty())
          inputs.add(getAdults());
          else
              inputs.add("1");
  
          if(!getChilds().isEmpty())
          inputs.add(getChilds());
          else
              inputs.add("0");
  
          if(!getRate().isEmpty())
          inputs.add(this.rate.get(0).toString());
          else
              inputs.add("1");
  
          if(!getBdgFixed().isEmpty()) 
          inputs.add(this.BdgFixed.get(0).toString());   
          else
              inputs.add("Yes");
  
          if(searchModel.createMessage(inputs) == "SUCCESS")
          {
          System.out.println("SUCCESS");
          setHotelsList(searchModel.getHotelsList());
          return "SUCCESS";
          }
          System.out.println("Failed");
          return "SUCCESS";
      }
      /* Search for the distance      
      public String Search(){
  
  
      /*//Search for Suggestion
      public String Search(){
          System.out.println("In Search method");
          SearchModel sm = new SearchModel();
          sm.retrieveItems(getCity().toString());
          return "SUCCESS";
      }*/
      public String getCity() {
          return City;
      }
  
      public void setCity(String city) {
          City = city;
      }
  
      public String getHighRate() {
          return HighRate;
      }
  
      public void setHighRate(String highRate) {
          HighRate = highRate;
      }
  
      public List getHotelsList() {
          return HotelsList;
      }
  
      public void setHotelsList(List hotelsList) {
          HotelsList = hotelsList;
      }
  
      public String getAdults() {
          return Adults;
      }
  
      public void setAdults(String adults) {
          Adults = adults;
      }
  
      public String getChilds() {
          return Childs;
      }
  
      public void setChilds(String childs) {
          Childs = childs;
      }
  
      public List&lt;String&gt; getBdgFixed() {
          return BdgFixed;
      }
  
      public void setBdgFixed(List&lt;String&gt; bdgFixed) {
          BdgFixed = bdgFixed;
      }
  
      public List&lt;String&gt; getRate() {
          return rate;
      }
  
      public void setRate(List&lt;String&gt; rate) {
          this.rate = rate;
      }
  
  }
  </code></pre>
  
  <p>I used <code>%{nameVar}</code> also but the value is still empty. :( someone help plz </p>