• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to retrieve the values of radio buttons using servlets?  RSS feed

 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




when the see the result i just get a strange value as "ON" but I am not getting the required value ,I mean Male or Female.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to properly indent your code.

Are you sure that the code you posted is up-to-date? The "on" value is what would be expected from a default checkbox.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, having post and get do the same thing is a bad practice. Don't do it.

Because you are using a get, you should see ?sex=Male on the URL after submitting. What do you see?
 
Ron McLeod
Saloon Keeper
Posts: 1562
222
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a servlet mapping from login to /Logs, or is your form getting submitted to the wrong servlet? I took your code, added the mapping, and it worked as you expected.

 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks

I was feeling ill thats why I failed to check this blog for the past few days.

The code here is upto date and I am using the same url pattern as /Logs in web.xml.

I am getting ?sex=on in the URL

Then in the main page i am getting the value for sex as null on

I dont know why I am not getting the value for sex.
This is my web.xml




 
Ron McLeod
Saloon Keeper
Posts: 1562
222
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the feature in your browser to examine to the HTML code received from the server. It sounds the value attributes are missing for the radio input elements.
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What feature you are reffering to ???
 
Ron McLeod
Saloon Keeper
Posts: 1562
222
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The browsers I use (Chrome, FireFox, IE) all offer a View Source or View Page Source capability.
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah its working in mybrowser now..

But not working in my eclipse
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My advice is not to run web apps in the IDE. As you are seeing now, it wastes time fighting with the IDE when it's clear that the code is working. I advise running and testing your web apps outside of any IDE.
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Bear

You mean just to run the server and check the working of the code in browser??
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what I do. I use an IDE (IntelliJ) only as a smart editor. I run and test my web apps separately in a Tomcat instance.
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok Mr.Bear Bibeault , I ll too practice the same. Thank you
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Curmudgeon-mode) Yet another example of an IDE leading someone astray - master the simpler tools which can actually be understood!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!