Skip to content Skip to sidebar Skip to footer

How To Use Request.getParameterValues?

I'm trying to pass an array from one jsp page to another using a hidden form. Here is the relevant code of my jsp files.

You can get is as string in lineup.jsp and you can split it with the same special characters like the following:

<%
   String players = request.getParameter("players");
   String[] s = players.split("::");
%>

Solution 2:

String[] players = request.getParametervalues("nameOfTheHiddenField");

Please try specifying a name for the hidden field and it will work.


Solution 3:

OK, s is null here hence s[0] throws NullPointerException

The method getParameterValues() will generally come into picture if there is a chance of getting multiple values for any input parameter, this method will retrieve all of it values and return it as string array.

but in your case I think you have only one value to fetch, use request.getAttribute and try to print the result i.e. s and not s[0]

once s is not null , you can go for s[0]


Post a Comment for "How To Use Request.getParameterValues?"