Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html:radio

 
Abigail Moore
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am new to Java...

I want to use html:radio tags to show a series of radio button in my jsp:

<tr><html:radio property="billOptions" value="1"> All Bill Months</html:radio></tr>
<tr><html:radio property="billOptions" value="2">Current</html:radio></tr>
<tr><html:radio property="billOptions" value="3"> In Progress</html:radio></tr>
<tr><html:radio property="billOptions" value="4"> Custom Bill Months</html:radio></tr>
<tr><html:radio property="billOptions" value="5"> Custom Bill Dates</html:radio></tr>

I am setting billOptions in my form to value 2 - so current is checked.
How do I get the value that the user picks - do I have to iterate through billOptions to see what they choose?
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using request.getParameter("billOptions") then it will return "1" or "2" etc depending on which they selected.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What framework are you using?

<html:... is not a part of core JSP.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably Struts.

Tracey, it'd behoove you to work through a JSP and Servlets tutorial. This is a very basic concept and being new to Java, getting the basic concepts under you belt will help you greatly goging forward.
 
Abigail Moore
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you all! I am using struts.

I will use request.getParameter - thanks.

Does anyone know of a good tutorial that covers this sort of question. I have taken a few tutorials but haven't seen this information.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I cannot imagine any JSP/Servlet tutorial worth its salt not covering how to retrieve submitted parameters.

You might want to consider picking up a book geared towards the beginner. You can visit the JavaRanch Bunkhouse for recommendations. "Head First Servlets and JSP" has garnered a lot of good reviews.
 
Stefan Evans
Bartender
Posts: 1717
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes request.getParameter("billOptions") will work.

But seeing as you are using Struts, the better way is to access it via your ActionForm.

form.getBillOptions(); (It does have that method right?)

The whole point of struts is that it takes the values from the jsp page and puts them into a java object for you (your ActionForm).
Having said that, you need a good understanding of html/jsp/servlets before struts really makes sense.

Cheers,
evnafets
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, personally I would never recommend usage of Struts for a beginner.
 
Abigail Moore
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for all responses. that is the way I had it - form.getBillOptions but was second guessing myself.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"tpeter3327",

You have changed your display name to one that is invalid. Take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Accounts with invalid display names are removed.

bear
Forum bartender
[ July 12, 2005: Message edited by: Bear Bibeault ]
 
R kr
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if i have to assign value to html:radio dynamically(like using <jsp:getProperty or <bean:write) what should i do and how?
Thanks in advance.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
R kr
Welcome to JavaRanch!

We're pleased to have you here with us in the JSP forum, but there
are a few rules that need to be followed, and one is that proper names are
required. Please take a look at the
JavaRanch Naming Policy and
adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

You can change it here
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic