wood burning stoves 2.0*
The moose likes Servlets and the fly likes How to pass the radio button attribute checked=true from the Java servlet to JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to pass the radio button attribute checked=true from the Java servlet to JSP" Watch "How to pass the radio button attribute checked=true from the Java servlet to JSP" New topic
Author

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

Hs Raveendran
Greenhorn

Joined: Feb 05, 2010
Posts: 23

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

Joined: Mar 22, 2000
Posts: 12761
    
    5
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

Joined: Jan 19, 2011
Posts: 77
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

Joined: Jan 10, 2002
Posts: 60822
    
  65

Why the redundant .toString()?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Prashant Chindhade
Ranch Hand

Joined: Jan 19, 2011
Posts: 77
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

Joined: Jan 10, 2002
Posts: 60822
    
  65

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

Joined: Jan 19, 2011
Posts: 77
ya i know man...
 
wood burning stoves
 
subject: How to pass the radio button attribute checked=true from the Java servlet to JSP
 
Similar Threads
How values of a radio button selected can be retained
Using EL to generate attribute/value pairs inside of an XHTML element
Session expires ,user session expires when online
How to retain the values after page refresh.
get disabled values from HttpServletRequest parameter