Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

197
Vistas
JSP and AJAX for stock quotation

As an exercise, I'm trying to create a simple page where you have two stock quotation, set to starting values 100 and 200. The methods updateValues() modify the quotation value by +/-1% and the displayAction() method return the String "<name of the quotation> = <value of the quotation>". Anyway, if I click the button "Refresh Values" the two quotation doesn't change. Wat I'm doingo wrong?
Here's my index.jsp:

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<jsp:useBean id="enel" class="it.unitn.studenti.porcelli.leonardo.esamefebbraio2022.businessobject.Enel" scope="application"></jsp:useBean>
<jsp:useBean id="webuild" class="it.unitn.studenti.porcelli.leonardo.esamefebbraio2022.businessobject.WeBuild" scope="application"></jsp:useBean>
<!DOCTYPE html>
<html>
<head>
    <title>PWEB Banking</title>

</head>
<body>
<script>
    function startIsClicked(){
        document.querySelector("#start_button").disabled = true;
        document.querySelector("#stop_button").disabled = false;
    }
    function stopIsClicked(){
        document.querySelector("#start_button").disabled = false;
        document.querySelector("#stop_button").disabled = true;
    }
    function refreshValues(enel, webuild){
        const xhttp = new XMLHttpRequest();
        xhttp.onload = function (){
            const newEnelValue = <%enel.updateValue();%>;
            document.getElementById("Enel").innerHTML = enel.displayAction();
            const newWebuildValue = <%webuild.updateValue();%>;
            document.getElementById("Webuild").innerHTML = webuild.displayAction();
        }
        xhttp.open("GET", "index.jsp", true);
        xhttp.send();
    }

</script>
<div id="buttons">
    <button id="start_button" type="button" name="start" onclick="startIsClicked()">Start</button>
    <button id="stop_button" type="button" name="start" onclick="stopIsClicked()" disabled>Stop</button>
</div>
<div id="Enel">
    <%=enel.displayAction()%>
</div>
<div id="Webuild">
    <%=webuild.displayAction()%>
</div>
<button type="button" onclick="refreshValues(<%=enel%>, <%=webuild%>)">Refresh Values</button>
<br/>
</body>
</html>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda