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 7196133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:43:11+00:00 2026-05-28T20:43:11+00:00

I am using spring 3 JSP tab lib to generate HTML. I have a

  • 0

I am using spring 3 JSP tab lib to generate HTML. I have a select box with following code –

<form:select path="categoryList" multiple="false">
                <form:option value="" label="--" selected="selected"/>
                <form:options items="${categoryList}" itemValue="catId" itemLabel="catName"/>
            </form:select>  

HTML getting generated is –

    <select id="categoryList" name="categoryList">
<option selected="selected" value="">--</option>
<option value="1" selected="selected">S</option>
<option value="2" selected="selected">Ster</option>
<option value="3" selected="selected">ice</option>
<option value="4" selected="selected">Cees</option>
</select>

Issue is all options getting generated has selected=”selected” which makes “Cees” selected on page rather then “–“. Can someone please let me know ohw to fix this?

complete page –

    <form:form modelAttribute="productManagerVO" name="productManager" id="productManager">
    <jsp:directive.include file="../common/header.jsp" />
    <div class="MainDiv">
        <div class="ManagerHeadline">Product Manager</div>      
            <table cellspacing="2px" cellpadding="0" width="100%">
                <tr>
                <td width="100%">
                    <fieldset>
                        <legend class="checkoutlegend">Category Information</legend>
                        <table align="left" id="addCategoryTable">
                        <tr><td><input type="button" id="addCat" value="Add New Category" /></td></tr>
                        </table>
                        <c:if test="${not empty productManagerVO.categoryList}">
                            <table cellspacing="2px" cellpadding="0" class="timeTable" id="categoryTable">
                                <th>Name</th>
                                <th>Order</th>
                                <th>Active</th>
                                <th>&#160;</th>
                                <c:forEach var="categoryListVO" items="${productManagerVO.categoryList}" varStatus="item">
                                <tr>
                                    <td><c:out value="${categoryListVO.catName}" /></td>
                                    <td><c:out value="${categoryListVO.catOrder}" /></td>                                   
                                    <td><c:if test="${categoryListVO.categoryActive}">Yes</c:if>
                                    <c:if test="${!categoryListVO.categoryActive}">No</c:if>
                                    </td>
                                    <td><a href="#editCategory" id="cat"  onclick="editCategoryData('${categoryListVO.catId}')">edit</a></td>
                                </tr>
                                </c:forEach>
                            </table>
                        </c:if>
                    </fieldset>
                </td>
                </tr>
                <tr>
                <td width="100%">
                    <fieldset>
                        <legend class="checkoutlegend">Product Information</legend> 
                            <table align="left" id="addProductTable">
                                <tr>
                                    <td><input type="button" id="addPro" value="Add New Product"/></td>
                                </tr>
                            </table>                    
                             <table cellspacing="2px" cellpadding="0" class="timeTable" id="productTable">
                             <col width="10%" />
                             <col width="7%" />
                             <col width="40%" />
                             <col width="10%" />
                             <col width="5%" />
                             <col width="6%" />
                             <col width="7%" />
                             <col width="10%" />
                             <col width="5%" />

                             <tr>
                                <th>Name</th>
                                <th>Subname</th>
                                <th>Description</th>
                                <th>Veg</th>    
                                <th>Spicy</th>
                                <th>Is Active</th>  
                                <th>Price</th>  
                                <th>Category</th>   
                                <th>&#160;</th> 
                            </tr>
                            <c:if test="${not empty productManagerVO.productList}">
                                <c:forEach var="productListVO" items="${productManagerVO.productList}" varStatus="item">
                                    <tr>
                                    <td><c:out value="${productListVO.fName}" /></td>
                                        <td><c:out value="${productListVO.fSubname}" /></td>
                                        <td><c:out value="${productListVO.fDesc}" /></td>
                                        <td><c:if test="${productListVO.fVeg}">Yes</c:if>
                                            <c:if test="${!productListVO.fVeg}">No</c:if></td>
                                        <td><c:if test="${productListVO.fSpicy}">Yes</c:if>
                                            <c:if test="${!productListVO.fSpicy}">No</c:if></td>
                                        <td><c:if test="${productListVO.fActive}">Yes</c:if>
                                            <c:if test="${!productListVO.fActive}">No</c:if></td>
                                        <td><c:out value="${productListVO.fPrice}" /></td>
                                        <td><c:out value="${productListVO.categoryName}" /></td>
                                        <td><a id="product" href="#editProduct" onclick="editProductData('${productListVO.fId}')">edit</a></td>
                                    </tr>
                                </c:forEach>
                            </c:if>
                             </table>
                    </fieldset>
                </td>
                </tr>
            </table>
        </div>
<div style="display:none">
    <div id="addCategory">
            <table cellspacing="2px" cellpadding="0" class="adminTable" style="border:1px solid #dadada;">
                <tr>
                    <td style="font-weight:bold;">Category Name</td>
                    <td><input type="text" id="caddName" /></td>                
                </tr>                   
                <tr>                
                    <td style="font-weight:bold;">Category Description</td>
                    <td><input type="text" id="caddDesc" /></td>    
                </tr>
                <tr>                
                    <td style="font-weight:bold;">Category Order</td>
                    <td><input type="text" id="caddOrder" /></td>   
                </tr>
                <tr>
                    <td style="font-weight:bold;">Is Active</td>
                    <td>Yes <input type="radio" value="y" name="catActive"/> No <input type="radio" value="n" name="catActive"/></td>
                </tr>
                <tr>
                    <td colspan="2"><input type="button" id="cSave" name="catSave" value="Submit" onclick="addNewCategory();"/></td>
                </tr>
            </table>
        </div>
    <div id="editCategory">
        <table cellspacing="2px" cellpadding="0" class="adminTable" style="border:1px solid #dadada;">
            <tr>
                <td style="font-weight:bold;">Category Name</td>
                <td><input type="text" id="ceName" name="ceName"/></td>             
            </tr>                   
            <tr>                
                <td style="font-weight:bold;">Category Description</td>
                <td><input type="text" id="ceDesc" name="ceDesc"/></td> 
            </tr>
            <tr>                
                <td style="font-weight:bold;">Category Order</td>
                <td><input type="text" id="ceOrder" /></td> 
            </tr>
            <tr>
                <td style="font-weight:bold;">Is Active</td>
                <td><input type="radio" id="ceActiveY" name="cateActive" value="y"/> Yes
                    <input type="radio" id="ceActiveN" name="cateActive" value="n"/> No</td>
            </tr>
            <tr><td colspan="2"><input type="button" id="cSave" name="catSave" value="Submit" onClick="editSaveCategory();"/></td>
            <td><input type="hidden" id="ceId"/></td>               
            </tr>
        </table>
    </div>
    <div id="addProduct">
        <table cellspacing="2px" cellpadding="0" class="adminTable" style="border:1px solid #dadada;">
            <tr>
                <td style="font-weight:bold;">Product Name</td>
                <td><input type="text" id="paName" /></td>              
            </tr>   
            <tr>                
                <td style="font-weight:bold;">Product SubName</td>
                <td><input type="text" id="paSubName" /></td>   
            </tr>               
            <tr>                
                <td style="font-weight:bold;"> Product Description</td>
                <td><input type="text" id="paDesc" /></td>  
            </tr>
            <tr>                
                <td style="font-weight:bold;">Price</td>
                <td><input type="text" id="paPrice" /></td> 
            </tr>
            <tr>
                <td style="font-weight:bold;">Is Vegetarian</td>
                <td>Yes <input type="radio" id="paVeg" name="proVeg" value="y"/> No <input type="radio" id="paVeg" name="proVeg" value="n"/></td>
            </tr>
            <tr>
                <td style="font-weight:bold;">Is Spicy</td>
                <td>Yes <input type="radio" id="paSpicy" name="proSpicy" value="y"/> No <input type="radio" id="paSpicy" name="proCpicy" value="n"/></td>
            </tr>
            <tr>
                <td style="font-weight:bold;">Is Active</td>
                <td>Yes <input type="radio" id="paActive" name="proActive" value="y"/> No <input type="radio" id="paActive" name="proActive" value="n"/></td>
            </tr>
            <tr>
                <td style="font-weight:bold;">Category</td>
                <td>
                <form:select path="categoryList" multiple="single">
                    <form:option value="" label="--"/>
                    <form:options items="${productManagerVO.categoryList}" itemValue="catId" itemLabel="catName"/>
                </form:select>              
                </td>
            </tr>
            <tr>
                <td colspan="2"><input type="button" id="caSave" name="cataSave" value="Submit"/></td>
            </tr>
        </table>
    </div>
    <div id="editProduct">
        <table cellspacing="2px" cellpadding="0" class="adminTable" style="border:1px solid #dadada;">
            <tr>
                <td style="font-weight:bold;">Product Name</td>
                <td><input type="text" id="peName" /></td>              
            </tr>   
            <tr>                
                <td style="font-weight:bold;">Product SubName</td>
                <td><input type="text" id="peSubName" /></td>   
            </tr>               
            <tr>                
                <td style="font-weight:bold;"> Product Description</td>
                <td><input type="text" id="peDesc" /></td>  
            </tr>
            <tr>                
                <td style="font-weight:bold;">Price</td>
                <td><input type="text" id="pePrice" /></td> 
            </tr>
            <tr>
                <td style="font-weight:bold;">Is Vegetarian</td>
                <td>Yes <input type="radio" id="peVegY" name="proeVeg" value="y"/> No <input type="radio" id="peVegN" name="proeVeg" value="n"/></td>
            </tr>
            <tr>
                <td style="font-weight:bold;">Is Spicy</td>
                <td>Yes <input type="radio" id="peSpicyY" name="proeSpicy" value="y"/> No <input type="radio" id="peSpicyN" name="proeSpicy" value="n"/></td>
            </tr>
            <tr>
                <td style="font-weight:bold;">Is Active</td>
                <td>Yes <input type="radio" id="peActiveY" name="proeActive" value="y"/> No <input type="radio" id="peActiveN" name="proeActive" value="n"/></td>
            </tr>
            <tr>
                <td style="font-weight:bold;">Category</td>
                <td>
                    <form:select path="categoryList" multiple="single" id="peCat">
                    <form:option value="" label="--"/>
                    <form:options items="${productManagerVO.categoryList}" itemValue="catId" itemLabel="catName"/>
                </form:select>  
                </td>
            </tr>
            <tr><td>
                <td colspan="2"><input type="button" id="peSave" name="proeSave" value="Submit" onClick="editSaveProduct();"/></td>
                <input type="text" id="peId"/></td>
            </tr>
        </table>
    </div>
</div>
</form:form>
  • 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-05-28T20:43:12+00:00Added an answer on May 28, 2026 at 8:43 pm

    Try removing the selected=selected on your first item. I don’t think its necessary as the list will display in the order you specified – unless you want — to be the default selection if the form is submitted without this select being touched?

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

Sidebar

Related Questions

I have a JSP that is using Spring:form tags to bind controls to a
I'm using Spring. I've got a JSP with a form:select in it displaying the
I'm using Spring Web Flow (v. 1.0.5) and I have a JSP page that
Using Spring 2.5 tag library, I have an Integer value in a command form
I am using Spring MVC 3.0 I have a guestbook.jsp page where I want
Is there an easy, not using spring, way to have RESTeasy return a jsp
I am using spring framework 3. I have a form for posting comments to
I am using Spring security 3.0.6 . The following JSP snippet is the culprit
I have a jsp application (using Spring) that uses a couple of global variables.
I'm using spring 3.0, in my jsp i have a couple of checkboxes (the

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.