This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retaining Radio Button Values After Refresh

 
Ati Sai
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
  •  
    Ati Sai
    Greenhorn
    Posts: 3
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Pie
    Posts: 64182
    83
    IntelliJ IDE Java jQuery Mac Mac OS X
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 3
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you so much for your prompt response.
     
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic