0

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?

martieva
  • 131
  • 2
  • 11

1 Answers1

0

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.

khalid jarrah
  • 1,561
  • 5
  • 14
  • 18
  • check it: http://stackoverflow.com/questions/16643798/how-to-get-the-value-from-javascript-code-to-jsp-scriptlet-with-in-the-same-jsp – khalid jarrah Oct 13 '13 at 06:42
  • khalid , if you dont mind can u give me some code for in ajax to do this action , since i want to do some operation at serverside based on the value i selected in the drop list, how could i get these selected value into scriplet to do serverside logic. ? – user2870368 Oct 13 '13 at 06:50
  • OFCOURSE ITS SO HARD TO GIVE A YOU CODE ,DIFFERENT SPECIFICATION , YOU HAVE TO SEARCH , SO START NOW : http://stackoverflow.com/questions/11645517/ajax-on-auiselect-liferay/11884079#11884079 @user2870368 – khalid jarrah Oct 13 '13 at 07:00