Menu

Simple step by step instructions for servlet

Help
2007-08-26
2013-04-25
  • Dennis Schaaf

    Dennis Schaaf - 2007-08-26

    Hey,

    I've been looking for really fundamental instructions for deploying a servlet. I can get it to the point where it deploys but then I don't know what address to call it under.

    -> I copied the code form the example and compiled it
    -> I included the xml-rpc stuff in the WEB-INF/lib folder
    -> I dropped it in the webapps folder (from tomcat) and the deploy folder from JBoss and watched the log messages say that the app is deployed
    -> I visited server/xml-rpc/ and tried various ways of calling there (with ruby xmlrpc/client) but keep getting 404's or temporarily moved errors.

    Where do i actually visit my webapp, is there maybe simple instructions around that i could follow?

    dennis

     
    • Greger Ohlson

      Greger Ohlson - 2007-08-30

      Hi Dennis,

      I'm really sorry to respond so slowly; for some reason my montioring setting had disappeared from SF so I didn't get an email about you message.

      Anyhow, the XML-RPC servlet is deployed just like any servlet which you are doing according to your message. This means that a web application with only the XML-RPC library and your services would look like this unzipped:

      WEB-INF/
        web.xml
        lib/
          xmlrpc-1.1.jar
        classes/
          your/
            package/
              structure/
                SomeInvocationHandler.class
                YourExtendedXmlRpcServlet.class
               
      Now, YourExtendedXmlRpcServlet is the class that extends redstone.xmlrpc.XmlRpcServlet. The servlet registers whatever invocation handlers that you want the servlet to dispatch to when messages arrive. In the documentation instances of the built-in Java classes java.util.Random and java.util.HashMap are registered, but normally you would register instances of classes that you have written like SomeInvocationHandler above, which must also be included in your web application.

      Finally, before zipping up this directory structure you must configure your web.xml to point out which servlets your web application contains. In this case, the only servlet you have is your.package.structure.YourExtendedXmlRpcServlet. The servlet mapping in web.xml indicates on which URL pattern the servlet should be triggered by the servlet container. Historically this is "/RPC2" like in the documentation.

      So, depending on where your web application is deployed in your container your servlet may be reached on http://<host>:<port>/<application-context>/RPC2 which is the URL you should use in your XML-RPC client. So http://127.0.0.1/RPC2 may be used when testing the example in the documentation, on your local host. In other words, the XmlRpcServlet works like any servlet but interprets the payload in the HTTP POST as an XML-RPC message.

      Hope this helps.

      Regards,
      Greger Olsson

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.