Solved

Data Passing through HTML and JSP

Posted on 2002-06-26
13
334 Views
Last Modified: 2010-04-01
Hi, me again.

I have 3 forms, Form1, Form2 and Form3. All of them are in JSP code.

Form 1 is data entry for user to key in customer ID. Form2 is view the result information of that specific customer. Third one is for update some of the customer information.

I have a problem for passing the CustomerID from Form1 to Form3.

Form1.jsp
=========
//No problem for this pages.

....
....
<form action="Fom2.jsp" method="POST">
...
...
//Button Submit pressed
<Input type="text" name="CustID">
...
...

Form2.jsp
=========
// This pages manage to capture user input for customerID

...

<% String cust=request.getString("CustID") ;
out.println(cust);
%>
....
<input type="hidden" value="request.getParameter("CustID")name="cust2">

...
...
//No problem...

Form3.jsp
========
//I need to pass the CustomerID from Form1.jsp to here for retrieve another table.
//What I do is in the form2, I put a hidden input, and try to pass the variable to Form3 through the Form2. But it's fail.

I also set the parameter in the
<action="Form3.jsp?CustID=cust method="POST">

but it's fail also...

Any other recommandation on my approach on getting my parameter pass correctly?

Thank you.


0
Comment
Question by:foongkim
  • 6
  • 6
13 Comments
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 7109961
Try adding the following to both forms in Form2 and Form3:

<input type="hidden" value="<%= request.getParameter("CustID") %>" name="CustID">
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 7109968
>> <action="Form3.jsp?CustID=cust method="POST"> ?

First of all, i think (and that's true) that JSP and HTML will not integrates themselves normally.

so this should be:

<action="Form3.jsp?CustID=<%=cust%> method="POST"> ??

or using javascript to set the form's Action Property dynamically??

but i think you should look into Session instead of passing the form variables.

You can set the Session variable by:

session.setAttribute("variable_name", value);

and use session.getAttribute("variable_name") to get the session value.

Example:
http://www.macromedia.com/support/ultradev/building/arrow_aircraft5/arrow_aircraft5_07.html

regards
0
 

Author Comment

by:foongkim
ID: 7112949
Oh Good, I love u all....

ryancys, since u touch the session, I encounter that coding before. But I thought the session is preset in API or is a separate method coded by programmer (us)?
And how to used that and the fucntione of that??
0
 

Author Comment

by:foongkim
ID: 7112971
On the second, form2, I type in

<% String Cust = request.getParameter("Customer"); %>
...
..
<form method="form3.jsp?CustCode=<%= Cust %>" method="POST
">
...
...

On the Thrid form, Form3:

<% String abc= request.getParameter("CustCode"); %>
Hi, <%= abc %>

...
....


But this return Null to me....... "Hi, null".

******
And if i put the variable in hidden format...... Bingo, it's run...
return exactly the Customer Code I key in at the first form.... Thank you...
But is't that the both way also work??


0
 
LVL 92

Expert Comment

by:objects
ID: 7112975
did u try my suggestion?
0
 

Author Comment

by:foongkim
ID: 7113000
As i mentioned, I did try your solution and it's working. And I am wondering why the <action="form3.jsp?<%=..... />
doesn't work.

Thank you, objects!
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 92

Expert Comment

by:objects
ID: 7113009
I don't see where the 'Customer' parameter is being set for the following to work:

<% String Cust = request.getParameter("Customer"); %>

0
 

Author Comment

by:foongkim
ID: 7113031
Sorry typing error, (it's correct in my programs).

It's should be

<% String Cust = request.getParameter("CustID") %>.

in the second form, FOrm2.jsp and the "CustID" is from Form1.jsp.

But when I call the thrid form, form3.jsp, which pass my "Cust" to it using <=action="Form3.jsp?CustID=<%=cust%> method="POST">, it's doesn't work!!
0
 
LVL 92

Expert Comment

by:objects
ID: 7113039
Not sure what the problem is.
What appears in the html produced by form2.jsp?
0
 

Author Comment

by:foongkim
ID: 7113049
It's doesn't work mean when I display the content of the parameter I passes (cust), it's return null.
Didn't pass it correctly. But ur suggestion, hidden method work well....
0
 
LVL 92

Expert Comment

by:objects
ID: 7113058
Understand that. Was just wondering exactly what html form2 was producing. But doesn't matter, as long as yuor codes working now :-)
0
 

Author Comment

by:foongkim
ID: 7113067
Exactly, it's working now. Thank you.
0
 
LVL 92

Expert Comment

by:objects
ID: 7115391
No worries :-)

http://www.objects.com.au/staff/mick
Brainbench MVP for Java 1
http://www.brainbench.com
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
When Does RestAdapter establishes HttpConnection 5 198
servlet concurrency 13 91
authenticate preemptively soap ui option 3 123
dateFashion java challenge 9 132
With more and more people tethered to the internet, advertisers can reach you in new and creative ways. Push notifications on your smartphone, customized advertisements based on your previous searches, and email inboxes filled with promotional pitch…
Note: This is the second blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   Every month t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

947 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

19 Experts available now in Live!

Get 1:1 Help Now