i have code like this
in page1.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html xmlns="http://www.w3.org/1999/xhtml">

    <body>
        <h1>Test</h1>

        <script language="javascript">
            function JSGetSelectedItem() {
                var dropdownIndex = document.getElementById('lang').selectedIndex;
                var dropdownValue = document.getElementById('lang')[dropdownIndex].text;
                alert("Hello JSCript " + dropdownValue);
            }

        </script>

        <!-- to fill combobox i had get from database -->   

        <form method="post" action="page1.jsp"> >
            Please select
            <select name="lang" onChange="JSGetSelectedItem()">
                <c:forEach var="v_Init" items="${ma_Init}">
                    <option value="scem">${v_Init.schem}</option>
                </c:forEach>
            </select>
        </form>

        <a href="page2.jsp?lang="<%=request.getParameter("lang")%> >Your Select</a>

    </body>
</html>

in page2.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Page 2</title>
    </head>
    <body>

     <%
      String selectedValue=request.getParameter("lang");
      out.println("Selected Value is : "+selectedValue);
     %>

    </body>
</html>

thanks

try it this way

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html xmlns="http://www.w3.org/1999/xhtml">

    <body>
        <h1>Test</h1>

        <script language="javascript">
            function JSGetSelectedItem() {
                var dropdownIndex = document.getElementById('lang').selectedIndex;
                var dropdownValue = document.getElementById('lang')[dropdownIndex].text;
                alert("Hello JSCript " + dropdownValue);
            }
 
        </script>
  
        <!-- to fill combobox i had get from database -->   

        <form method="post" action="page2.jsp"> >
            Please select
            <select name="lang" onChange="JSGetSelectedItem()">
                <c:forEach var="v_Init" items="${ma_Init}">
                    <option value="scem">${v_Init.schem}</option>
                </c:forEach>
            </select>
           <input type = "button" value = "submit" id = "submit"/>
        </form>
    </body>
</html>

just change the form action to paje2.jsp. then add a button. i usually do the same and it works.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.