aspose file tools*
The moose likes JSP and the fly likes JSP sending and recieving data from html Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP sending and recieving data from html" Watch "JSP sending and recieving data from html" New topic
Author

JSP sending and recieving data from html

Tempora Telora
Ranch Hand

Joined: Jun 20, 2005
Posts: 83
I completely forgot how to set the hidden variables and be able to pass it to another jsp..

I know i need to create a function ie sumbitClick ( argument, argument)
but i dont know what to do inside the function


For example i have FName and LName as the fields for input and i have LastName and FirstName has hidden variables to be passed..

How do i set LastName and FirstName and be able to pass it to another jsp.


Once I get it over i know i just do like <% firstName = FirstName %> or something like that? Maybe not?

Thank you,
Randy
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

How are you getting from one JSP to the other? Form submission?

If so, and as you state:

For example i have FName and LName as the fields for input and i have LastName and FirstName has hidden variables to be passed..


you already have form fields with the data, why do you need to copy the same data to hidden fields?
[ June 01, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

If FName and LName are already input fields (<input type="text"> ,
you don't need to put their value into hidden fields.
If there are contained in your form, they will be sent when you submit the form.

For example:

No need to use hidden fields. You can retrieve the values in secondJsp.jsp, with EL : ${fname} and ${lname}.


[My Blog]
All roads lead to JavaRanch
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Originally posted by Satou kurinosuke:
You can retrieve the values in secondJsp.jsp, with EL : ${fname} and ${lname}.


I think, ${fname} would return (write in out) something only if any scope has attribute with name 'fname'. But here, fname is parameter.

Am I right?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

Yes, you are right. The parameters will be available from the builtin param scoped vairable.
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Originally posted by Bear Bibeault:
Yes, you are right. The parameters will be available from the builtin param scoped vairable.


like,

${param.fname}

Tempora Telora
Ranch Hand

Joined: Jun 20, 2005
Posts: 83
I have an input field name of lname and value of lastname. Lastname is initialized to "". I want once the user clicks the submit button i need to send that data to the function so i can set my hidden and then go to the new form..

I am using forms. The name of hte form is myform. In my function i have document.myform.LastName.value = passed variable.

the only problem is that my passed variable is always null.

here is what i have

on
click = " sumbit('<%= lastname%>')"

it will always send nothing though

any ideas?

Thank you,
Randy
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

Your language is very imprecise so it's not entirely clear what you are asking or trying to do. Let me try to clarify things. Please be sure to answer any questions that I ask in this reply or we cannot help you.

Originally posted by Randy Tatham:
I have an input field name of lname and value of lastname.


So lname is <input type="text" name="lname">.

A "value of lastname" doesn't tell us anything. I'm assuming from later code snippets that you mean a JSP scripting variable named lastname?

Lastname is initialized to "".


Where and how?

I want once the user clicks the submit button i need to send that data to the function


What is "that data" and what function?

I am using forms. The name of hte form is myform. In my function i have document.myform.LastName.value = passed variable.


What is "LastName"? You haven't mentioned it before? Did you mean the "lname" field?

here is what i have

on
click = " sumbit('<%= lastname%>')"


What is "submit"? A function you defined?

it will always send nothing though


If "lastname" is a scripting vairable that contains the empty string, then why are you surprised that <%= lastname %> evaluates to the empty string?
[ June 02, 2006: Message edited by: Bear Bibeault ]
Tempora Telora
Ranch Hand

Joined: Jun 20, 2005
Posts: 83
Ok lets try this again.....

Tell me if i get this even close to being right.

I have an input field. The name of the input field is lname.

I want to send lname to a function to be able to pass it to another jsp.

I have hidden variables that are being passed via the form.

I am setting the hidden variable via the input from the text field with the text in the lname text field.

ie

input= text name= lname
0nclick = submit(*pass something here*)

submit(lastname)
mydocument.blah.value = lastname
etc.


Any ideas?
[ June 02, 2006: Message edited by: Randy Tatham ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61657
    
  67

Originally posted by Randy Tatham:

I want to send lname to a function to be able to pass it to another jsp.


This is the question I asked at the very beginning: Why?

If you've already got the value in a text field, it will be "passed" to the JSP that the form is being submitted to. Why do you feel the need to do anything else?

You're either completely over-thinking the problem, or not conveying the reason that you feel the need to do all this copying around.
Tempora Telora
Ranch Hand

Joined: Jun 20, 2005
Posts: 83
You are completely right. WoW i love trying to do the hardest thing possible when the easiest way is right infront of ur face.. ty for ur help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP sending and recieving data from html