Solved

Data Passing through HTML and JSP

Posted on 2002-06-26
13
335 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 50

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Knowing where your website is hosted is as important as the features you receive, the monthly fee, and the support you receive. Due diligence should be done when choosing your next hosting provider.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

773 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