File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Getting drop down value in JSP as request scope. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Getting drop down value in JSP as request scope." Watch "Getting drop down value in JSP as request scope." New topic
Author

Getting drop down value in JSP as request scope.

amarshi mohanty
Ranch Hand

Joined: Jul 01, 2008
Posts: 110
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

SCJP (97%), SCWCD (95%))
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2896
    
    1

Try this:


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
amarshi mohanty
Ranch Hand

Joined: Jul 01, 2008
Posts: 110
This shows 5 as always selected.

Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2896
    
    1

You have to play around.
Try,


Also, whether to use "5" or 5, depends upon the type of "docsPerPage".
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 639
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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Getting drop down value in JSP as request scope.
 
Similar Threads
How to show the selected value in a jsp after the page submissin.
Drop down values
Adding <c:if> to option tag
Getting the selected option
Show the selected value in dropdown again