Solved

Data Passing through HTML and JSP

Posted on 2002-06-26
13
339 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
[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
  • 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 52

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
Independent Software Vendors: 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!

 

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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

For anyone that has accidentally used newSID with Server 2008 R2 (like I did) and hasn't been able to get the server running again because you were unlucky (as I was) and had no backups - I was able to get things working by doing a Registry Hive rec…
This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 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