0

I have a form made in jsp page, which allows user to store some values of a product like name, category & many more.

Below is my form in a brief way:

            <div class="element">
                    <label for="element">Product name </label>
                    <input id="name" name="name" class="text  err" />       
                </div>


                    <div class="element">
                    <label for="category">Category </label>                     
                    <select id='stateCombo'  onchange='stateComboChange();'>
       <option value='-1' title='-select one-'>-select one-</option>
       <option value='0' title='Mobile'>Mobile</option>
       <option value='1' title='Nsw'>Routers</option>
      <option value='2' title='Tas'>Datacard</option>
      <option value='' title='Tas'><%=request.getAttribute("category") %></option>

    </select>
                                              </div>

Now my main focus is on category element. I want to show category values from db as option within select tag. I have used list in request.setAttribute("category",list) where list contains category name values from db.

But my output shows like:

  [universe.shopping.dto.Category@33008c73]
   [universe.shopping.dto.Category@33008c73, universe.shopping.dto.Category@6904ec2d]


          "universe.shopping.dto.----"   this is my bean class package

I have created bean class and using list i'am getting values from db.

In short i need to know best possible way to store values from database within option in a drop down manner within select tag.

1
  • did my answer work for you? Would appreciate it if you could indicate it with the checkmark. Commented Sep 19, 2013 at 11:24

1 Answer 1

1

You cannot just print a list as it is in jsp. What your output shows is the reference to the list and not the actual values in the list.

you can loop through the list using jstl tags as explained in this answer.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.