a thoretical question: my button gets its initial value from the var "message" defined at the beginning of my JSP file. lets say the value of "message" is changing later. how can i make my button's value tag updated too?
<% String message = "Hello!" %>
<input id="mybutton" type="button" value="<%=message%>/>
preguntado el 29 de julio de 12 a las 02:07
You will have to change the variable to its final value before the variable is rendered. If you want to update a value on the web page using server data after it has been rendered you can either refresh the page or make an ajax request to the server to retrieve the latest data. Do a Google search for jQuery and Ajax for more information on how to do this.
Here's an article to get you going:
Implementación de Ajax en una aplicación web Java usando JQuery http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=438#start
var message = <% "Hello" %>
message, that has a value that is set when the jsp is evaluated.
obviously, this example is silly, but if you replace hello with some variable in Java-land, it's much more useful.
Also note, that you can't update a value with a scriptlet after the page is rendered. You will have to use Ajax.