This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

how to get the text box value

Mag Yeoh
Ranch Hand

Joined: Oct 08, 2006
Posts: 42
i having problem with pass the jsp text box value to java file.....
for example...i have one text box name is 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

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

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

Joined: Oct 26, 2006
Posts: 28
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:

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

Joined: Oct 08, 2006
Posts: 42
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....





when i click on save button in add2.jsp that time i cannot run the method in 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....

Stefan Evans

Joined: Jul 06, 2005
Posts: 1517
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)

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

Mag Yeoh
Ranch Hand

Joined: Oct 08, 2006
Posts: 42
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:
subject: how to get the text box value
It's not a secret anymore!