• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Drop down population Issue.  RSS feed

 
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi Folks,
Im developing a jsp page where I set the value obtained from a dropdown to insert into a database.
Im using java script to fetch the value of the dropdown in the jsp , and then use the value for processing in the servlet. Im able to pass the value of the dropdown successfully here .
Its something like this..


However , when I click on a value in the dropdown the page submits as expected and the form is submitted to the Servlet , which processes the request,but when the page reloads after submission the dropdown value is lost and is set to the default "--Select--" value , any ideas where i could be going wrong ?

  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Vic Hood,
Once the page is submited, the response is commited. When the page reloads after submission the request is new request hence the value whichever you set before submit will not be available. If you need to maintain the value you had assigned to the 'd-down' drop down you need to set the value to the 'd-down' attribute in the servlet and get the value form the request attribute in jsp and set that value to the 'd-down'
 
Marshal
Posts: 67193
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to put the selected attribute on the <option> that you wish to be selected. Otherwise it defaults to the first choice.
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bang on target,Bear!
Thanks a lot
 
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!