I got some outside help and can imagine the right solution. To offer a complete but simple setup, I use an html file for data entry (but this can be done at the pier, as was done above).
<?xml version="1.0" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Data input</title> </head> <body> <form action="http://localhost:8080/" method="post"> <textarea name="input" cols="4" rows="20"></textarea> </p> <input type="submit" value=" Send"/> </form> </body> </html>
The jruby part of the confusion is simple;):
require 'java' Dir["./Java/jetty-6.1.18/lib/*.jar"].each { |jar| require jar } Dir["./Java/lib/jsdk2.1/javax/*.jar"].each { |jar| require jar } include_class 'javax.servlet.http.HttpServlet' include_class 'org.mortbay.jetty.Server' include_class 'org.mortbay.jetty.servlet.Context' include_class 'org.mortbay.jetty.servlet.ServletHolder' def main server = Server.new(8080) context = Context.new(server, '/', 0) servlet = TestServlet.new() holder = ServletHolder.new(servlet) context.addServlet(holder, '/') server.start() end class TestServlet < HttpServlet def doPost(request, response) input = request.getParameter('input') response.writer.println(" <html> <head><title>Output</title></head> <body> Raw input: <pre>#{input}</pre> </body> </html>") request.handled = true end end main
To collect data sent via GET, simply specify doGet in the same way.
source share