Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8670521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:43:33+00:00 2026-06-12T18:43:33+00:00

I have the following code in my jsp: <c:forEach var=value items=${MyList} varStatus=loop> <tr><td><div id=Name1>Here:${value.name}</div></td></tr>

  • 0

I have the following code in my jsp:

<c:forEach var="value" items="${MyList}" varStatus="loop">
  <tr><td><div id="Name1">Here:${value.name}</div></td></tr>
  <s:hidden id="Name" name="Name" value="%{value.name}"/>

the html source is as following:

     <tr><td><div id="Name1">Here:My name is X</div></td></tr>
     <input type="hidden" name="Name" value="" id="Name"/>

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 ${value.name} but ran into this error: “According to TLD or attribute directive in tag file, attribute value does not accept any expressions”

My completed JSP is as following:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Register</title>
</head>
<body>
    <div id="Search">
        <label for="message">Travel details</label>
    <table border="1">


    <s:form action="Search_Search" >


      <td>
      <s:textfield name="City" label="City" /></td>
      <td><s:textfield name="HighRate" label="Budget" /></td>
      <td><s:textfield name="Adults" label="Adults"/></td>
      <td><s:textfield name="Childs" label="Child (less 15)"/></td>
      <td><s:select label="Prefered hotel rate" name="rate" list="rate" value="no preference"/></td> 
      <td><s:textfield name="Days" label="Days"/></td>
      <td><s:radio label="Is the budget fixed" name="BdgFixed" list="BdgFixed"
            value="defaultBudget"/>
      <td><s:submit/></td>

      </s:form>


    </table>


    </div>

    <sx:div>
                <table border="1">
                <tr>
                <c:forEach var="Hotel" items="${HotelsList}" varStatus="loop">
                 <c:set var="nameVar" scope="request" value="${Hotel.name}"/>
                 <c:if test="${not loop.first and loop.index % 3 == 0}">
                   </tr><tr>
                 </c:if>
                <td>

                  <div id="HotelInfo">



         <td>
         <s:form action="Search_AddHotel" >
         <tr><td><div id="image"><img src=${Hotel.thumbNailUrl} alt="image"/></div></td></tr>
           <s:textfield name="Name3" label="Budget" />  
         <tr><td><div id="Name1">Here:<c:out value="${nameVar}"/></div></td></tr>
         <s:hidden id="Name" name="Name" value='${nameVar}'/>
         <s:label id="name2" name="name2" value="John"/>
         <tr><td><div id="Highest Rate:">Rate:${Hotel.highRate}</div></td></tr>
         <tr><td><div id="Address">Address:${Hotel.address}</div></td></tr>
         <tr><td>
                      <s:submit/>
        </s:form>

         </td></tr>
          </td>

               </c:forEach>
                    </tr>
                </table>
   </sx:div>

</body>
</html>

My completed Java class is as following:

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<String> BdgFixed;
    private List<String> 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<String>();
        BdgFixed.add(Yes);
        BdgFixed.add(No);

        rate = new ArrayList<String>();
        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<String>();


        //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<String> getBdgFixed() {
        return BdgFixed;
    }

    public void setBdgFixed(List<String> bdgFixed) {
        BdgFixed = bdgFixed;
    }

    public List<String> getRate() {
        return rate;
    }

    public void setRate(List<String> rate) {
        this.rate = rate;
    }

}

I used %{nameVar} also but the value is still empty. 🙁 someone help plz

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:43:34+00:00Added an answer on June 12, 2026 at 6:43 pm

    Try not to use property names like value, key, etc., because they could be reserved keywords.

    So change value to something different and see if is this works.

    EDIT:
    Change this
    <s:hidden id="Name" name="Name" value='${nameVar}'/>

    to
    <s:hidden id="Name" name="Name" value="%{nameVar}"/>

    Update:

    If you want to use forEach tag then use
    <input type="hidden" name="Name" value="${nameVar}">

    or use <s:iterator> tag with
    <s:hidden id="Name" name="Name" value="%{nameVar}"/>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following JSP code: <c:forEach items=${requestScope.XX} var=x> <tr> <td><input type=radio value=${x.xID} name=x></td>
I have following line of code for jsp tag <input name=UnicodeVirtualKey class=btn type=button value=&#x0A85;
I have the following code: index.jsp: <form name=f action=db/ajoutConducteur.jsp method=post> <input type=text pattern=\d{8} required
I have a Struts 2 jsp with the following code... <s:iterator value=categories id=category status=iteratorStatus>
I have been trying to modify the following code in JSP from here :
I have the following code in my JSP. <td style=text-align:center;><s:property value=accountCode/></td> when i get
I have the following code in a jsp page (Struts backed): <c:if test=${USERINFO.someproperty ==
I have the following code. <s:push value=#session['person']> <s:if test=%{admin=='y'}> <a class=add href=/projit1/project/addProject.jsp>Create a Project</a>
i am new in JSP,i have some problem with the following code : <%@
I have following code <div id=main> <div id=one> </div> <div id=two> </div> <div id=three>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.