I have been trying to get the contents of the comma separated string like
"RAVI, PRASHANT, ANKIT, PANKAJ, Nilesh Kumar Mishra, Anoop Kumar"
Each element in this list needs to be displayed in the dropdown menu in a JSP page. The JSP code doing this bit goes like this:
<select class="style1" id="id" placeholder="sample placeholder" >
<c:forEach var="name" items="${fn:split(names, ',')}">
<option value="${name}">${name}</option>
</c:forEach>
</select>
But after the page is rendered i notice that if output for ${name} contains any whitespace the words after the whitespace are getting rendered as the attributes inside option tag.
<select class="style1" id="id" placeholder="sample placeholder" >
<option value="RAVI">RAVI</option>
<option value="PRASHANT">PRASHANT</option>
<option value="ANKIT">ANKIT</option>
<option value="PANKAJ">PANKAJ</option>
<option value="Nilesh" kumar="" mishra="">Nilesh Kumar Mishra</option>
<option value="Anoop" kumar="">Anoop Kumar</option>
</select>
I tried some searching for the solution and came across with the SO link. But solution provided is for the PHP and also i am unable to find the equivalent for htmlspecialchars in JSP.
Can anybody help me in avoiding those unintended attributes and instead get the whole string as a value for 'value' attribute in the option tag, just like the first three are getting rendered?
Thanks in advance.