Im trying to write a webrick servlet to process a html form.
Im using the post method to send, NOT get (in the html form).
I have require 'cgi' in my servlet.
But I keep getting:
Method not allowed
unsupported method 'post'
Any ways to get around this or am I doing something wrong?
···
--
My Blog: http://27degrees.blogspot.com
James McCarthy <mccarthyjames@gmail.com> writes:
Im trying to write a webrick servlet to process a html form.
Im using the post method to send, NOT get (in the html form).
I have require 'cgi' in my servlet.
But I keep getting:
Method not allowed
unsupported method 'post'
Any ways to get around this or am I doing something wrong?
--
My Blog: http://27degrees.blogspot.com
A WEBrick servlet is not a CGI, so, doing require 'cgi' is just a
gratuitous exercise, unless you want to use some of cgi's convenience
methods like CGI::escape, unescape, parse, etc.
A servlet accepts method POST if it has a method do_POST(request,
response):
E.g.:
class FooServlet < HTTPServlet::AbstractServlet
def do_POST(req, resp)
resp['content-type'] = 'text/plain'
resp.body << "You posted the following content:\n"
resp.body << req.body
end
end
YS.
cheers, exactly what I was looking for.
···
A servlet accepts method POST if it has a method do_POST(request,
response):
E.g.:
class FooServlet < HTTPServlet::AbstractServlet
def do_POST(req, resp)
resp['content-type'] = 'text/plain'
resp.body << "You posted the following content:\n"
resp.body << req.body
end
end
YS.
--
My Blog: http://27degrees.blogspot.com