Solved

Retrieving form field values

Posted on 2004-04-30
7
400 Views
Last Modified: 2012-06-22
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
Comment
Question by:badri_nana
7 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 10957864
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
 
LVL 7

Accepted Solution

by:
searlas earned 63 total points
ID: 10957896
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
 

Author Comment

by:badri_nana
ID: 10957957
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
 
LVL 32

Assisted Solution

by:ldbkutty
ldbkutty earned 62 total points
ID: 10957966

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
 
LVL 7

Expert Comment

by:searlas
ID: 10958353
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
There's a lot of hype surrounding blockchain technology. Here's how it works and some of the novel ways it' s now being used - including for data protection.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question