• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Display the Selected DropDown Value to another JSP Page

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, im a newbie in JSP Programming,

i have a simple PRogram that can display/add/delete/edit the value from the database.. in my homePage.jsp i have one DropDown Menu this is filter the record.. my problem is in my AddRecord.jsp. because if a user select a value on the DropDown Menu ex. PAGE-1 and click ADD button, what i want to do is to display on the DROPDOWN is the SELECTED value of PAGE-1. but its not working instead when i SELECT PAGE-1 from the DropDown and Click ADD button, the value of dropdown in AddRecord that jsp will be back to empty which the user need to select the value again..

this for quick understanding..hope so...

ex. i have a car collection program. which is categorized according to brand name. and if i select the brand FERARI and i want to add new car in this category.. it will automatically display my selected FERARI then add the new can to it.....

hope it will help... sorry for my poor english..

thank you for some help..
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Place the selected attribute on the option element that you want to be selected in the drop down.
 
Daryll sabate
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
honestly i dont get it.. as i've said im just a pure newbie in jsp.. so its sounds like chinese to me..

here is my code..

Homepage.jsp




on that.. when i select a value on the dropdown, and click ADD.. it will display the nextpage which is InsertReport.jsp

InsertReport.jps code:


what i want is..when i select a value a value of dropdown in HomePAge.jsp and click ADD what i want to see in the next page is the SELECTED VALUE FROM HomePage.jsp is Display to InsertReport.jsp automatically..


hope you will understand.. thanks
 
Bear Bibeault
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As a novice to JSP it's important that you learn JSP correctly and you're on a very bad track.

After the introduction of JSP2 in 2002 -- yes, 10 years ago - putting Java code, and especially database code, into a JSP is considered an unacceptable practice. It still exists for compatibility with legacy applications, but any JSP written after 2002 should be using the JSTL (JSP Standard Tag Library) and EL (Expression Language) in place of Java scriptlets.

I'd also recommend reading the following articles:
  • The Secret Life of JSPs
  • The Front Man

  • But what it comes down to is as easy as this: if you want a particular option in the drop down to be selected, you put the selected attribute on the option. For example:
    <option value="whatever" selected>Whatever!</option>

    Frequently the EL's ternary operator is useful for this. For example:
     
    Hey, I'm supposed to be the guide! Wait up! No fair! You have the tiny ad!
    Smokeless wood heat with a rocket mass heater
    https://woodheat.net
    reply
      Bookmark Topic Watch Topic
    • New Topic