?
Solved

Data Passing through HTML and JSP

Posted on 2002-06-26
13
Medium Priority
?
344 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 200 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 54

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
Tech giants such as Amazon and Google have sold Alexa and Echo to such an extent that they have become household names. And soon they are expected to be used by commoners in their homes, ordering takeout, picking out a song, answering trivia questio…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

830 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