I just have to increment values from 0 to 23 using <c:foreach> tag in select box. This is the code snippet

 <html:select property="schStartTimeHH" styleClass="tableDataTextStyle1">                                        
           <c:forEach var="i" begin="0" end="23"> 
                                                <html:option value ="<c:out value="${i}"/>"><c:out value="${i}"/></html:option>

the value of the option tag is hitting an error. Can any one suggest the correct format of it

Edited by Dani: Formatting fixed

8 Years
Discussion Span
Last Post by Thirusha

What error are u getting, the code seems fine to me, Do u have a form bean of schStartTimeHH?


i am getting the following error:
org.apache.jasper.JasperException: /jsp/addapiService.jsp(507,47) Unterminated &lt;html:option tag

ie the error occurs in

<html:option value ="<c:out value="${i}"/>">

part i suppose.


I am by no means a genius in jsp, i too am still learning, so i have no clue as to why it is not working but i have figured out a "work around"
The first thing i tried is to remove the double quotes so i coded the html:option part like this:

<html:option value='<c:out value="${i}"/>' >

that got rid of the error, but when i viewed the source code, it turns out the code was being displayed like this :

<select><option value="<c:out value="${i}"/>" >1</select></select>

So the work around:
I just removed the html:option tags and replaced them with the standard option tags like this:

<html:select property="schStartTimeHH" >
<c:forEach var="i" begin="0" end="23">
    <option value='<c:out value="${i}"/>'><c:out value="${i}" /></option>

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.