Solved

Retrieving form field values

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

HOW TO: Install and Configure VMware vSphere Hypervisor 6.5 (ESXi 6.5), Step by Step Tutorial with screenshots. From Download, Checking Media, to Completed Installation.
In  today’s increasingly digital world, managed service providers (MSPs) fight for their customers’ attention, looking for ways to make them stay and purchase more services. One way to encourage that behavior is to develop a dependable brand of prod…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now