aspose file tools*
The moose likes JSP and the fly likes how to get the text box value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "how to get the text box value" Watch "how to get the text box value" New topic
Author

how to get the text box value

Mag Yeoh
Ranch Hand

Joined: Oct 08, 2006
Posts: 40
i having problem with pass the jsp text box value to java file.....
for example...i have one text box name is CountryName.....how i want to pass the value keyin in the text box to java file....i only can pass the value from i only can pass the value from add.jsp to add1.jsp.....

This is add.jsp
----------------------------------------------------------


-----------------------------------------------------
Problem
1. i want to know how to pass the value in the text box to java file/method.


------------------------------
add1.jsp
---------------------------------
when in add1.jsp...i click on save, i need to pass in the text box value into the java file...
Natasza Biecek
Greenhorn

Joined: Oct 26, 2006
Posts: 28
hi,
using scriplet for example...
this is code of small page which receives & prints posted data


by the way...
Originally posted by Mag Yeoh:



your form will submit data regardles of pressed button...
try this way:


Natasza
[ October 30, 2006: Message edited by: Natasza Biecek ]
Mag Yeoh
Ranch Hand

Joined: Oct 08, 2006
Posts: 40
now i having problem is i cannot pass the text box value to the java method...
when i click save that time i having error.....can you help me lot of my code....

----------------
add.jsp
----------------


--------------------------
add2.jsp
-------------------------


--------------------------
Country.java
---------------------------

--------------------------------------------

when i click on save button in add2.jsp that time i cannot run the method in Country.java file....actually after i click save button in add2.jsp, i need to run the setData method in the java file....but how can i pass the countryName and countryPopulation to run inside the setData method....

Thanks....
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
Well the parameters are only submitted from add1.jsp to add2.jsp.
They are not present when you submit add2.jsp (you have no inputs on the form on add2.jsp)

Solutions
1 - Make country a Session scoped bean. That means it will retain values between requests
2 - Put hidden fields on add2.jsp so that the parameters will resubmit themselves

ie
Mag Yeoh
Ranch Hand

Joined: Oct 08, 2006
Posts: 40
it is possible that i only use 2 page of jsp file???when i click on the save button it will display the successful save data in the second page......

base on my coding it is possible to do that....
sorry for late reply....
Thanks a lot...
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
What you need is a good book or a nice tutorial of Servet and JSP.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get the text box value