Home » Java » Pass Javascript variable to java in jsp

Pass Javascript variable to java in jsp

Posted by: admin July 19, 2018 Leave a comment


After getting the user_name on client side using the below code :

<script type="text/javascript">
        var WinNetwork = new ActiveXObject("WScript.Network");
        var user_name = WinNetwork.UserName;

I was blocked how to pass the value of the variable “user_name” to the java code below,in order to test if this user exists on an oracle table :

    try {           
        ResultSet rs1 = stmt
                .executeQuery("select * from utilisateur where upper(login) like upper('" + user_c + "')");

        if (!rs1.next()) {
            int i6 = stmt.executeUpdate("insert into utilisateur(login) values('" + user_c + "')");
    catch (Exception e) {