avalle Active Member Licensed User Longtime User Jul 1, 2018 #1 Hi I need to read an array of parameters from the payload of an HTML form that is POST-ed to my B4J server. I normally use Code: Copy Dim mydata As String = req.GetParameter("mydata") to read a single parameter "mydata". My payload also contains multiple parameters like Code: Copy text[0]=thisIsTextElementOne&text[1]=thisIsTextElementTwo&text[2]=thisIsTextElement&... What should I do to read these "text[n]" parameters into a "text" array? Thanks Andrea
Hi I need to read an array of parameters from the payload of an HTML form that is POST-ed to my B4J server. I normally use Code: Copy Dim mydata As String = req.GetParameter("mydata") to read a single parameter "mydata". My payload also contains multiple parameters like Code: Copy text[0]=thisIsTextElementOne&text[1]=thisIsTextElementTwo&text[2]=thisIsTextElement&... What should I do to read these "text[n]" parameters into a "text" array? Thanks Andrea
stevel05 Expert Licensed User Longtime User Jul 1, 2018 #2 I haven't used this, but I assume you the object req is a ServletRequest Object. It seems that code like this would do what you want. You will need to provide the parameter names in the order you want them stored. Code: Copy Dim Params As String = Array As String("ParamName1","ParamName2","ParamName3") Dim Data(Params.Length) As String For i = 0 To Params.Length -1 Data(i) = Req.GetParameter(Params(i)) Next Or look at using the ParameterMap Upvote 0
I haven't used this, but I assume you the object req is a ServletRequest Object. It seems that code like this would do what you want. You will need to provide the parameter names in the order you want them stored. Code: Copy Dim Params As String = Array As String("ParamName1","ParamName2","ParamName3") Dim Data(Params.Length) As String For i = 0 To Params.Length -1 Data(i) = Req.GetParameter(Params(i)) Next Or look at using the ParameterMap
avalle Active Member Licensed User Longtime User Jul 1, 2018 #3 Thanks Stevel, however your code assumes a predefined list of parameters ("ParamName1", 2..., 3...). In my case the list of parameters is variable and unpredictable because the client can specify 0, 1 or multiple parameters "text[n]". I could use your code with a high enough number of parameters, but I would like to use a more flexible and efficient code that reads the existing parameters in a loop (or For Each). Upvote 0
Thanks Stevel, however your code assumes a predefined list of parameters ("ParamName1", 2..., 3...). In my case the list of parameters is variable and unpredictable because the client can specify 0, 1 or multiple parameters "text[n]". I could use your code with a high enough number of parameters, but I would like to use a more flexible and efficient code that reads the existing parameters in a loop (or For Each).
stevel05 Expert Licensed User Longtime User Jul 1, 2018 #4 Will the ParameterMap not work for you? You wouldn't need top know the parameter names in advance and you could use a For Each on the keys to iterate over the Map. Upvote 0
Will the ParameterMap not work for you? You wouldn't need top know the parameter names in advance and you could use a For Each on the keys to iterate over the Map.
avalle Active Member Licensed User Longtime User Jul 3, 2018 #5 stevel05 said: Will the ParameterMap not work for you? Click to expand... Yes it worked, thanks! Upvote 0