Solved

Data Passing through HTML and JSP

Posted on 2002-06-26
13
333 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
Comment Utility
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
Comment Utility
>> <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
Comment Utility
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
Comment Utility
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
Comment Utility
did u try my suggestion?
0
 

Author Comment

by:foongkim
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 92

Expert Comment

by:objects
Comment Utility
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
Comment Utility
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
Comment Utility
Not sure what the problem is.
What appears in the html produced by form2.jsp?
0
 

Author Comment

by:foongkim
Comment Utility
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
Comment Utility
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
Comment Utility
Exactly, it's working now. Thank you.
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
No worries :-)

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

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
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: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

6 Experts available now in Live!

Get 1:1 Help Now