| | |
How to assign the value in a text field to a variable in jsp using Java
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
If you want to use java it must be done at the server. Meaning before you render the page.
For example.
Put a value at the request
For example.
Put a value at the request
request.setAttribute("key","The Value") Then submit, redirect or whatever and at jsp, get it and put it at the field: JSP Syntax (Toggle Plain Text)
String something = (String)request.getAttribute("key"); ... <input type="text" name="someName" value="<%= something %>" />
Last edited by javaAddict; Jun 21st, 2009 at 12:25 pm.
Check out my New Bike at my Public Profile at the "About Me" tab
If you have a value in a textfield and want to put it in a java variable, you need to submit the form (or pass it as parameter at a hyperlink)
If you want to put a java variable to a textfield, when you go to the page you need to take it from the request and put it to the field when the page renders.
Remember first the code executes at the server and then the page is loaded. So you take the value from the request and then the field with the value will be displayed:
If you want to put a java variable to a textfield, when you go to the page you need to take it from the request and put it to the field when the page renders.
Remember first the code executes at the server and then the page is loaded. So you take the value from the request and then the field with the value will be displayed:
JSP Syntax (Toggle Plain Text)
String something = (String)request.getAttribute("key"); ... <input type="text" name="someName" value="<%= something %>" />
Check out my New Bike at my Public Profile at the "About Me" tab
Meaning put some value to a field and then push something so that this value would be put to a java variable?
Yes, submit the page.
When you see the JSP page, java code has already been executed. If you want to execute some more you need to go to the server by submitting.
If you have java code in a jsp page, that code is first executed at the server and then page is displayed.
So when you submit, the code that gets executed (getting values from the request) is at the server. When this is done, you see the page
Yes, submit the page.
When you see the JSP page, java code has already been executed. If you want to execute some more you need to go to the server by submitting.
If you have java code in a jsp page, that code is first executed at the server and then page is displayed.
So when you submit, the code that gets executed (getting values from the request) is at the server. When this is done, you see the page
Check out my New Bike at my Public Profile at the "About Me" tab
![]() |
Similar Threads
- Setting text field values in Java on JSP page (JSP)
- problem with text field.. help (JSP)
- How to retrieve data multiple row data from oracle database rable and show it on jsp (JSP)
- populating text field in firefox not working (JavaScript / DHTML / AJAX)
- Searching a Text Field in a JList (Java)
- JSP and Servlet Display of text in a text field (JSP)
- javascript variable in jsp session (JSP)
Other Threads in the JSP Forum
- Previous Thread: Retrieval and comparison of a value stored in a MySQL database
- Next Thread: How to get mysql output to table as a link?
Views: 1060 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for JSP
apache array backbutton combobox comma connection csv database development directorystructure dropdownlist dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 mysql netbeans network parameters passing ping printinserverinsteadofclient project read redirect request.getparameter response seperated servlet servletdopost()readxml sessions software sql ssl state_saving_method stocks sun tomcat tutorial update values video web write






