haven't done much JSPs, hence an elementary question. I was writing a JSP in which I was using more than one forms. Idea was to get only selected parameters and not others, present on different form on submition. However, a colleague of mine has serious objection on it without any convincing answer. Just wanted to know if it is bad programming or whatever. What is the problem if I use more than one form within a JSP ?
Thanks for your time.
As a general rule, you want to modularize your work. Lots of forms in a single JSP is like a spaghetti-code method that tries to do lots of things with lots of "if" statements.
It is better to split each form up into a different JSP.
There are no problems with using multiple forms within a single JSP. However, it does require that you think through why you would need them and is there a cleaner more programmatic way to solve the problem.
I use more than one form basically as a simple way to navigate that is transparent to the user. For example, if a user clicks a link to load a form that allows them to create a user account. I will provide a form that had a Submit button and a Cancel button. The Cancel, although it looks like it is part of the form, is actually a separate form that redirects the user to where I want them should they cancel the form submission.