• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 408
  • Last Modified:

Retrieving form field values

Hi,

I have a main jsp which has many jsp includes. Every jsp page has a form. Every form has certain form fields, hidden variables.
For eg, if I have a jsp J1 which has 5 jsp's & 5 forms F1,F2,F3,F4,F5.
When I submit form F5, then I need to get the values of all other form fields from forms F1 to F4.
Javascript cannot be used as per the specifications.
What option can be used to get the values of the hidden & form fields from other forms?

Thanks for your time and replies.

Regards
D.Badrinarayanan
0
badri_nana
Asked:
badri_nana
2 Solutions
 
TimYatesCommented:
I'm confused...  You have all forms up at once?  Or the user has to go through from F1 to F5 (in that order)?

If it's the latter, F1 -> F5 then have F1 post to F2, F2 stores F1's values in the session, F2 posts to F3, F3 stores F2's values in the session, etc

Then F5 posts to another page that can extract F1.a F1.b F1.c F2.a F2.b ...  F5.a etc

Basiclaly my answer is, save the form values in the session :-)

Hope I explained well enough, and hope this is what you meant...

If not, you may need to explain again what you mean :-)

Tim
0
 
searlasCommented:
If you have to send the data from all 5 forms on one page... don't use 5 forms.  Use 1.  You can easily
have the form tags in J1 and just have the input fields in all the JSP's you are including.

If you want to stick with 5 forms on 1 page, and you're not allowed to use JavaScript, you're
only choice is vbscript (IE only, of course.)  If you can't use vbscript, you can't do what you are trying to do.

Quite simple really.
0
 
badri_nanaAuthor Commented:
Hi,

I have a jsp A which includes JSP B, JSP C, JSP D, JSP E. All these jsp's each have one form & some fields inside that form. For eg,in form A in JSP A, I have a text field & a button. In form B of JSP B, I have a <select>. When I click on button in form A, I need the value of the option selected in <select> for certain processing. Since I am submitting form A, we cannot get the value of <select> of form B which is the problem.Ultimately the entire page will reload once I submit form A. All other forms also have <select>,textfield,buttons. There is a cyclical dependency between the form fields.For eg, form A's text field's value would be needed for creating the query when I submit another form B.
I hope I cleared your doubt.
Now in such a scenario, will it be possible to get all the form field values?
Thanks for your reply and time.

Regards
Badri
0
 
ldbkuttyCommented:

You cannot perform single submission for FIVE forms...Instead, the following would be a better option and i am using it right now for my application.

J1.jsp:
.........

<form method="post" action="actionpage.jsp" name="J1">
<table>
  <tr>
   <td>

      <jsp:include page="jspfirst.jsp" flush="true"/>
      <jsp:include page="jspsecond.jsp" flush="true"/>
      <jsp:include page="jspthird.jsp" flush="true"/>
      <jsp:include page="jspfourth.jsp" flush="true"/>
      <jsp:include page="jspfifth.jsp" flush="true"/>
     
      <% out.print("<table>   <tr>\n      <td>");
        out.print("<input type=\"submit\" value=\"Submit\">");
        out.print("<input type=\"hidden\" name=\"FormName\" value=\"J1\">);
         out.println("</td>\n     </tr>\n     \n    </table>"); %>

  </td>
</tr>
</table>
</form>


In jspfirst.jsp, just have the table to be displayed(no form):

..........
<table>
  <tr>
   <td>
      <% /* Your JSP/HTML Code with fields,...  */   %>
      </td>
  </tr>
</table>
..........

In jspsecond.jsp, just have the table to be displayed(no form):

............
<table>
  <tr>
   <td>
      <% /* Your JSP/HTML Code with fields,...  */   %>
      </td>
  </tr>
</table>
.............

And Similarly for other pages also....

So, the final SUBMIT Action wll submit all the fields including jspfirst.jsp,.....jspfifth.jsp.

Hope it helps...
0
 
searlasCommented:
Which spells out more clearly what I said here:
"You can easily have the form tags in J1 and just have the input fields in all the JSP's you are including."

We also do the same as ldbkutty, but with compile time <%@ include..%>
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now