How to send array from javascript to JSp -


in code need send array javascript jsp did many times , i'm unable output i'm getting array printing array please me i'm missing

my code is

   <%@page import="sun.security.util.length"%>    <%@ page import="java.util.list" %>    <%@ page language="java" contenttype="text/html; charset=iso-8859-1"    pageencoding="iso-8859-1"%>      <html>    <head>    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">    <title>insert title here</title>    <script>    function funct()    {    var h=localstorage.getitem('m');    location.replace("test1jsp.jsp?arr="+h);    }    </script>    </head>    <body onload="funct();">    <%    string arr[]=request.getparametervalues("arr");    list<string> larr = (list<string>)request.getattribute("arr");    for(int p = 0; p < 3; p++)    out.println((string)larr.get(p));    out.println(arr);    %>    </body> </html> 

you need construct query string correctly. can't slap array onto string , expect encoded.

you repeat key each value in array.

var h=localstorage.getitem('m'); var query_string = ""; h.foreach(function (value) {    if (query_string.length) {        query_string = query_string + "&";    }    query_string = query_string + "arr=" + encodeuricomponent(value); }  location.replace("test1jsp.jsp?" + query_string); 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

android - CoordinatorLayout, FAB and container layout conflict -