Requests

Let's now have a look at a typical HTTP request being submitted by a common browser to Helma:

GET /appname/main HTTP/1.1 
Host: localhost:8080 
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050317 Firefox/1.0.2 
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 
Accept-Language: en-us,en;q=0.5 
Accept-Encoding: gzip,deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
keep-alive: 300 
Connection: keep-alive 
Cookie: HopSession=127.0.0.zsy455yhwnbe 
If-None-Match: "O+nl/8BoDSesnGNp7ASjjw=="

The first word of the first line contains the HTTP method, which is generally GET. Also quite common is the HTTP method POST, which can be used for submitting forms. Helma's standard actions handle all incoming GET, POST and HEAD requests, with the latter just returning the response header without the actual body. In case that a developer wants to differentiate between these methods, she can use req.isGet(), req.isPost() or req.method to detect the actual method of the current request.

But the HTTP protocol is not limited to just these methods (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html). An implementation of a REST API ( http://en.wikipedia.org/wiki/Representational_State_Transfer) for example, generally requires the handling of DELETE and PUT requests. WebDAV ( http://en.wikipedia.org/wiki/Webdav) even adds 7 more additional methods to the protocol. Helma provides a flexible way to handle all kind of possible methods separately. The developer can define special actions with their function names ending with '_action_methodname', i.e. '_action_delete', '_action_propfind' and so forth. A DELETE request to /appname/hello will initiate the execution of an action named 'hello_action_delete'.

As can be seen in listed sample request, all kind of other information is being passed along to the server besides the used HTTP method. This data is exposed to Helma application code through the request object 'req'. See the reference section for a detailed list of available methods and fields. Probably most important is the Object req.data, that allows access to any form data, url parameter or cookie value. A special case is the uploading of a file, which is being discussed later on. Additionally the class javax.servlet.http.HttpServletRequest is directly exposed via req.servletRequest.