This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSP and the fly likes How can code the selected value in the JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "How can code the selected value in the JSP" Watch "How can code the selected value in the JSP" New topic
Author

How can code the selected value in the JSP

nand rai
Greenhorn

Joined: Feb 17, 2009
Posts: 27

I have couple of drop downs in my jsp . User selects one of the option and submit the form ,which will get inserted into the database.

But when i retrieve the record for update on the JSP my drop down donot retain the previously selected option. How to code this. I am using simple JSP page.

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56201
    
  13

Set the selected attribute n the appropriate option element.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
neeha sharma
Greenhorn

Joined: Jun 12, 2009
Posts: 11
nand rai

suppose you have selected update option you check for VO.
In update case if data is in database then VO will not be null so you check for VO not null condtion.
If VO is not null then retrive the value and put select i mean
<option value="<%=exampleVOArray[i].getname()%>" selected>
Try this
Usman Saeed
Ranch Hand

Joined: May 21, 2008
Posts: 30


Usman Saeed
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How can code the selected value in the JSP
 
Similar Threads
Using html:select with string arrays
can anyone tell me how do we update the values in servlet?
Getting drop down value in JSP as request scope.
Populating DropDown Boxes
How to make a select option selected for a certain option?