javaservletsalfrescoweb-scripting

Difference between alfresco webscript and Java servlet


Recently I've discovered that document upload feature in Alfresco backed with a simple Java Servlet (UploadContentServlet.java). I don't understand why it is a servlet not a webscript. Since everwhere in Alfresco webscripts are used. Another question which pops up is what's the difference between Alfresco webscript and Java Servlet? They look almost the same, except the procedure to create them and that Alfresco WebScript response could be customized with some ftl template. Is there any other differences?


Solution

  • As you can find here Alfresco UploadContentServlet, UploadContentServlet is

    Responsible for streaming content directly from servers into the repository using the HTTP PUT command. The NodeRef of the node onto which the content will be streamed can be encoded into the URL. In this situation the content of the property can be considered to be updated once the servlet has returned.

    It is related to URL addressability, a topic that seems to be discontinued on newer Alfresco versions. By the way, I think that the reason could be that using a servlet is more efficient especially when uploading huge files.

    Mainly webscripts are easier to write and to mantain than servlets. Moreover if you change something in your server side javascript file all you have to do is to reload the container, instead of reloading the context of your application. This link may show you the architecture Web Script Framework and even if it is quite old the information is still valid for newer versions of the platform. Ftl templates are very useful and remember that the platform gives you a lot of root objects that you can use in your webscripts.