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>
                            </c:forEach>     
</html:select>

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

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>

</c:forEach>
</html:select>

thank u very much ur solution is working fine

My pleasure, please mark this thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.