• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass the radio button attribute checked=true from the Java servlet to JSP

 
Raveendran Hs
Greenhorn
Posts: 23
Eclipse IDE Java Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a two radio button in the JSP
I need to pass the radio button attribute checked=true from the Java servlet to JSP
How can achieve this
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you reading this status from a request submitted from a FORM? If you are forwarding to the JSP, the request will still have the status when the JSP gets it.

If this status comes from something else, information can be kept in the session.

How are you passing control from servlet to JSP?

Bill
 
Prashant Chindhade
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You write this in jsp file
<input type="radio" name="sex" value="Male">

you can simply write this in servlet
Sex=req.getParameter("sex").toString();

you will get value in string
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why the redundant .toString()?
 
Prashant Chindhade
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its an optional thing you can remove it and you will get same answer.
i have written it because i want that in string and to make sure it is string
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's redundant and should not be used. The method already returns a string and there's no need for the extra method.
 
Prashant Chindhade
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya i know man...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic