Solved

Retrieving form field values

Posted on 2004-04-30
7
401 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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
reflection example 3 118
maven webservice example issue 2 156
instanceof  operator in java 26 102
listing all functions in JavaScript 19 227
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

685 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