Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Display the Selected DropDown Value to another JSP Page

 
Daryll sabate
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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..
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64978
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64978
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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:
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic