wood burning stoves 2.0*
The moose likes Struts and the fly likes Multiple forms in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Multiple forms in JSP" Watch "Multiple forms in JSP" New topic
Author

Multiple forms in JSP

Rick Pellerin
Greenhorn

Joined: Mar 17, 2003
Posts: 8
I would like to have multiple "html:form" in my JSP but it doesn't seems to work...
Is there any restrictions?

I prefered to have multiple forms because I use the Validator framework and use the Client Side JS validation. If I have only one form (and use a DispatchAction), the JS is not valid anymore...My validations are depending on the button pressed.

Thanks
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

I believe there is a restriction to only allow one html:form tag per page.

Is it that some buttons should not cause validation at all or that some buttons do some validation while other buttons do some other validation?


A good workman is known by his tools.
Rick Pellerin
Greenhorn

Joined: Mar 17, 2003
Posts: 8
Yes, exactly!

I have a login page with:

a first form (for member) that contain a username/password fields.
a second form (for new member) that contain an activation code field

a third form (for supplier) that contain a username/password fields.
a fourth form (for new supplier) that contain an activation code field

Richard
Ray Stojonic
Ranch Hand

Joined: Aug 08, 2003
Posts: 326
I don't see anywhere where it states that there's a restriction of the number of html:forms per JSP, it certainly doesn't make any sense to have such a restriction...

Besides, I have several JSPs with multiple html:forms.

I can say that you can only have one html:form per html:form though, in other words: no nesting. (you can do it, but submitting the nested form will cause the outer form to submit, so the whole construct is always submitted and always goes to the same action)
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Ok, so Ray says you can have multiple html:forms on the page.

Does it work when you aren't using the JS validation, Rick?
Ray Stojonic
Ranch Hand

Joined: Aug 08, 2003
Posts: 326
On rereading my post I note it comes across a bit strong, that wasn't the intent...apologies for any unintended snubbing.

I haven't used js validation, but I have used regular validation, which seems to work just fine despite multiple forms. Each validation definition is tied to a specific ActionForm, and only one form is submitted at a time, so that's not much of a surprise. I would be interested to know how multi js validation works out.
Dhan Raj
Greenhorn

Joined: Jan 24, 2005
Posts: 12
Ray

I am trying to validate a List attribute (which has two attributes to itself) of a form , but I could not.

My posting is at the following URL(with Details):
http://www.coderanch.com/t/50763/Struts/Validation-List-property-Form

Can u suggest me, how I should do it?

Thanks
Dhan Raj
Rick Pellerin
Greenhorn

Joined: Mar 17, 2003
Posts: 8
Sorry for the delay...

Everything works OK if I don't use the JS validation...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple forms in JSP
 
Similar Threads
How to handle multiple action with in one page?
form action problem
Servlet Contrlloer Path Issue
Best practise to load javascript settings from server
is it good design having mutiple forms in a jsp