Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get the text box value

 
Mag Yeoh
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1687
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you need is a good book or a nice tutorial of Servet and JSP.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic