S
Scott Archer
I'm trying to use the Net::Http libraries to do a post request to a
java servlet.
I need to submit multiple parameters with the same name.
test=1
test=2
test=3
if I were submitting the form in html it would look something like this.
<html>
<body>
<form method="POST" action="test.servlet">
<input type="hidden" name="test" value="1" />
<input type="hidden" name="test" value="2" />
<input type="hidden" name="test" value="3" />
<input type="submit" name="submit">
</form>
</body>
</html>
This is the ruby code I am using currently.
url = URI.parse("http://localhost/test/test.servlet")
req = Net::HTTP:ost.new(url.path)
req.set_form_data({'test'=>['1','2']})
res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
case res
when Net::HTTPSuccess, Net::HTTPRedirection
xml = res.body
else
res.error!
end
puts xml
In the servlet I'm doing the following
String[] values = request.getParameterValues("test");
This should return an array with the String values ["1","2","3"]
It's returning an array with one value ["123"]
I know the java code is correct. I'm trying to migrate an existing
program to ruby, however this is the only stumbling block I've come
across.
I found this reference on the mailing list but there were no replies.
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/246557
Any help would be appreciated.
java servlet.
I need to submit multiple parameters with the same name.
test=1
test=2
test=3
if I were submitting the form in html it would look something like this.
<html>
<body>
<form method="POST" action="test.servlet">
<input type="hidden" name="test" value="1" />
<input type="hidden" name="test" value="2" />
<input type="hidden" name="test" value="3" />
<input type="submit" name="submit">
</form>
</body>
</html>
This is the ruby code I am using currently.
url = URI.parse("http://localhost/test/test.servlet")
req = Net::HTTP:ost.new(url.path)
req.set_form_data({'test'=>['1','2']})
res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
case res
when Net::HTTPSuccess, Net::HTTPRedirection
xml = res.body
else
res.error!
end
puts xml
In the servlet I'm doing the following
String[] values = request.getParameterValues("test");
This should return an array with the String values ["1","2","3"]
It's returning an array with one value ["123"]
I know the java code is correct. I'm trying to migrate an existing
program to ruby, however this is the only stumbling block I've come
across.
I found this reference on the mailing list but there were no replies.
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/246557
Any help would be appreciated.