Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Getting drop down value in JSP as request scope.

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In my jsp , i have a drop down box , which on select i am submitting the page.After submitting the page , i am dispalying the same page with the output based on the slectected value from the drop down box.
But after the page submitted the , selectd value from the drop down box is not shown , rather the first value in the drop down box is displayed by default.
So when i am submitting the page , i am putting the selected value in request scope .
Then in the jsp , i am using the below code in selected options as:



but it not working.
what will be correct code?


--- Amarshi
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this:

 
amarshi mohanty
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This shows 5 as always selected.

 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to play around.
Try,


Also, whether to use "5" or 5, depends upon the type of "docsPerPage".
 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

amarshi mohanty wrote:Hi,

In my jsp , i have a drop down box , which on select i am submitting the page.After submitting the page , i am dispalying the same page with the output based on the slectected value from the drop down box.
But after the page submitted the , selectd value from the drop down box is not shown , rather the first value in the drop down box is displayed by default.
So when i am submitting the page , i am putting the selected value in request scope .
Then in the jsp , i am using the below code in selected options as:



but it not working.
what will be correct code?


--- Amarshi



Did you look up the format for the <option> tag in HTML? You're not formatting it correctly.
For example, here's one description of the <option> tag: http://www.quackit.com/html/tags/html_option_tag.cfm
Then, look at the source of the response sent to your browser. Does it look right? If not, you should know how to correct the JSP now.
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic