Solved

Retrieving form field values

Posted on 2004-04-30
7
402 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
netstat -a in AIX unix 8 59
Exception creating bean of class 5 236
best tutorial on log4j and logging for servlets/jsp codes 1 68
servlet example 17 69
After hours on line I found a solution which pointed to the inherited Active Directory permissions . You have to give/allow permissions to the "Exchange trusted subsystem" for the user in the Active Directory...
This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

734 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