Return variable from jsp to another jsp

0

Hi, I have a jsp with the following function and I would like to know how to call it in another jsp ... Thanks to everyone!

 <script type="text/javascript">
       function getHeight(){
             var alto = document.getElementById('table').offsetHeight;
           return alto; 
       }
         
 
</script>
    
asked by Iron Man 09.03.2018 в 09:27
source

1 answer

1

<script type="text/javascript">
       function getHeight(){
             var alto = document.getElementById('table').offsetHeight;
             document.getElementById('elemHeight').value = alto;
           return alto; 
       }                  
</script>
<input type="hidden" value="-1" id="elemHeight" name="elem">

JSP

To collect the data in the JSP you just have to call the function getParameter() with the name of the element of your form, getParameter('elem')

The best option is to save the value in a hidden input and retrieve it in the JSP when you submit the form. To check that the value is passed correctly you initialize the "hidden" to -1 to check in the jsp that the value of the input is different from -1. If you do not have a form, you can create it even if only for that element.

    
answered by 09.03.2018 / 10:22
source