title: How can I create a servlet with jruby (running with jetty)?
body: <p>I am pretty new to jruby and java and want to create a servlet in jruby while using jetty as web server. I am not sure if I am on the right way with the following code which shows the input form so far. I guess I have to extend now the HttpServlet class to handle the posted data but I don't know how to do this in this case and if it is okay to do this in the same script.</p>
  
  <pre><code>require 'java'
  
  Dir["./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.ServletException'
  include_class 'javax.servlet.http.HttpServlet'
  include_class 'javax.servlet.http.HttpServletRequest'
  include_class 'javax.servlet.http.HttpServletResponse'
  
  include_class 'org.mortbay.jetty.Server'
  include_class 'org.mortbay.jetty.handler.AbstractHandler'
  include_class 'org.mortbay.jetty.servlet.Context'
  include_class 'org.mortbay.jetty.servlet.ServletHolder'
  
  def main
    handler = Handler.new
    server = Server.new(8080)
    server.setHandler(handler)
    server.start()
  end
  
  class Handler &lt; AbstractHandler
    def handle(target, request, response, dispatch)
      response.setContentType("text/html")
      response.setStatus(HttpServletResponse::SC_OK)
      response.getWriter().print('                                                          
         &lt;form action="RequestProcessing" method="post" enctype="multipart/form-data"&gt;              
         &lt;p&gt;Select a file:&lt;br&gt;                                                       
         &lt;input name="file" type="file" size="20" maxlength="1000" accept="text/*"&gt;   
         &lt;/p&gt;                                                                               
         &lt;input type="submit" value=" Send"/&gt;                                               
         &lt;/form&gt;')
      request.setHandled(true)
    end
  end
  
  class RequestProcessing &lt; HttpServlet
    # So what do we do here?
  end
  
  main
  </code></pre>
  
  <p>I would be thankful for any hints. Many thanks in advance!</p>