Question

I want to check which value I selected in a scriplet, when I press some value in the drop down list. How can I do that?

I tried as follows : ( below two codes are in the same page "test.jsp" )

code : for list 
    <select id="stream" name="current_session" onclick="fun2()" >
                <option value="Winter">Winter</option>
                <option value="Monsoon">Monsoon</option>
    </select>

code : scriplet inside a javascript ( note that both html, scriplet are in the same page )

     <script>
     function  fun2(){

     <%  
       String given_session=request.getParameter("stream"); 
       system.out.println(given_session);
     %>

    }

note : I am getting output as null, instead of selected session value. So how can get the selected values in scriplet which is in the same jsp page?

Was it helpful?

Solution

you can use a js to select the value

function get_the_value(){

var e = document.getElementById('stream').value;

return e; }

In your web browser you have only html, javascript and css. All JSP code is meant to be run on the server. So you get only the output of the jsp file. And after this you cannot change the jsp code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top