File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Problem using html:radio Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem using html:radio" Watch "Problem using html:radio" New topic

Problem using html:radio

Pranav Bhatt
Ranch Hand

Joined: Mar 20, 2006
Posts: 284
Hi all,
I have tried a lot and could not get a solution for my application. Actually i have a Jsp page which have two radio buttons that needs to get generated dynamically. I tried out with some options, but could not use them properly.
As am confused about using the html:radio tag so please bear with me.
here is my jsp-: check.jsp

here is the form bean-:

and here is my action -

the strut-config.xml

Now when am running my application am getting the error-:
javax.servlet.jsp.JspException: Cannot find bean: "CHOICES" in any scope

I have set CHOICES in request attribute still am getting error.

Later i tried to change the check.jsp as-:
<logic:iterate id="choice" name="checkbean" collection="CHOICES">
so name will be my bean name and collection would be the collection from action class. But i get another error as-:
javax.servlet.jsp.JspException: Cannot create iterator for this collection

Could anyone tell me how exactly i should use the tags and where am going wrong. I tried to google much but couldn't find a solution.

Pranav Bhatt
Ranch Hand

Joined: Mar 20, 2006
Posts: 284
Anyone on this? Am i going in right direction?
Pranav Bhatt
Ranch Hand

Joined: Mar 20, 2006
Posts: 284
Have solved it myself.. ... The tut misguided me by writing put collection in action and i was wondering how to pass the attribute to jsp.
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
Can you tell flow of Action and jsp calling?

I understands,

(here itself we should put CHOICES in session)>>check.jsp >> CheckAction>>checkSuccess.jsp

Pranav Bhatt
Ranch Hand

Joined: Mar 20, 2006
Posts: 284
Well yes actullay previously i was creating my collection inside the Action class so was having problem.
The flow as per my understanding is as-:
check.jsp->checkbean.jsp (for values in reset methods)->check.jsp(to fill form)->checkbean(for setters to set form fields)-> CheckAction (when finally i submit the form). in between the mapping relationships goes on backend as per struts-config.xml.

Actually when the control was coming to name="CHOICES" it was not able to find the collection in scope as it would check in my form bean and no collection is there in any scope with name "CHOICES".

So after keeping the collection in reset of my formbean am setting it in request scope. So now my jsp is able to find the collection to use as below-:

I had made some rough explanation hope it makes sense
I agree. Here's the link:
subject: Problem using html:radio
It's not a secret anymore!