This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Retaining Radio Button Values After Refresh Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Retaining Radio Button Values After Refresh" Watch "Retaining Radio Button Values After Refresh" New topic
Author

Retaining Radio Button Values After Refresh

Ati Sai
Greenhorn

Joined: Mar 01, 2012
Posts: 3
Hi,

I am trying to make a form that consists of several radio buttons. After clicking the submit button the result will be shown on the same page. I want to add this feature to my program so that after submitting the form and presenting the results, user can see his selected fields.

I have tried this code but it did not work.



"stat" is the name of my java package that I have called in this .jsp file and I have defined setcolor() and getcolor() in that java package.

Any suggestions or comments would be appreciated.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60800
    
  65

Two things:
  • Java scriptlets have been discredited for 10 years now. You should be using the EL and JSTL.
  • In Java, strings are not compared with == but with the .equals() method.
  • If you are expressing colors as numbers (that's wierd to being with), why are you storing the numbers as strings?


  • [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
    Ati Sai
    Greenhorn

    Joined: Mar 01, 2012
    Posts: 3
    Thank you for your response. I am very new to Servlets and JSPs development. Can you introduce a book or a good source that I can use?
    And with regards to colors and storing them as number, that was an example of what I am doing. In fact I am working on creating a calculator that its parameters should be entered via a form that consists of both textfields and radio buttons.
    Bear Bibeault
    Author and ninkuma
    Marshal

    Joined: Jan 10, 2002
    Posts: 60800
        
      65

    Make sure whatever book or tutorial that you use is up-to-date and focuses on the JSTL and EL rather than Java scriptlets.

    If you are new to JSP and servlets, I also recommend reading these articles:
  • The Secret Life of JSPs
  • The Front Man

  • Ati Sai
    Greenhorn

    Joined: Mar 01, 2012
    Posts: 3
    Thank you so much for your prompt response.
     
     
    subject: Retaining Radio Button Values After Refresh
     
    Similar Threads
    How to get the hidden field from JSP
    Pass radio button to servlet
    Using EL to generate attribute/value pairs inside of an XHTML element
    JSP Error
    setting a radio button