Object | +--res
| SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods |
| Properties Summary | |
Boolean |
cache
Specifies on a per-response base whether to allow client-side caching of the response or not. |
String |
charset
Sets the character encoding of the output. |
String |
contentType
Sets the content type of the HTTP response. |
Object |
data
Object providing space for custom output data. |
String |
error
Property containing an internal Helma error message. |
String |
etag
Get or set the HTTP ETag for this response. |
Object |
handlers
The res.handlers object is a container in the response object used to register macro handlers for the current request/response. |
Date |
lastModified
Sets the date the resource was retrieved by the remote client. |
String |
message
Buffers a string for output. |
Object |
meta
Object providing space for general purpose per request meta information. |
String |
realm
Sets the realm for a HTTP-authentication challenge This defines the realm for a HTTP-authentication challenge. |
HttpServletResponse |
servletResponse
Provides direct access to the servlet response header, a Java object of the class Packages.javax.servlet.http.HttpServletResponse Example: res.servletResponse.setHeader( "Content-Disposition", ( this.mimetype.startsWith( "image/" )? |
Array |
skinpath
The res.skinpath can be set to an array that tells Helma where to look for skinsets for the current request/response. |
Number |
status
Read/write property containing the response's HTTP-status code. |
| Methods Summary | |
void
|
abort()
Aborts the current transaction by throwing an Error |
void
|
commit()
Commits the current transaction, writing all changed objects to the database, and starts a new transaction. |
void
|
debug(<String> text)
Append any value to the output of the current page. |
void
|
dependsOn(<String> what)
Add an item to this response's dependencies. |
void
|
digest()
Digest this response's dependencies to conditionally create a HTTP not-modified response. |
void
|
encode(<String> textToEncode)
Writes a string as smooth HTML to the output buffer. |
void
|
encodeXml(<String> textToEncode)
Writes a string to the output buffer, replacing some characters with their equivalent XML entities. |
void
|
format(<String> textToFormat)
Writes a string as smooth HTML to the output buffer. |
void
|
forward(<String> path)
Serves a static file from the application's protectedStatic directory. |
String
|
getBuffer()
Provides access to the contents of the current repsonse buffer. |
String
|
pop()
Pops a string buffer from the response object and returns its string value. |
StringBuffer
|
popBuffer()
Pops the current response buffer without converting it to a string. |
void
|
push()
Pushes a new string buffer on the response object. |
void
|
pushBuffer(<StringBuffer> strBuffer)
Pushes a Java StringBuffer object on the reponse object. |
void
|
redirect()
Sends an HTTP redirect message to the client. |
void
|
reset()
Resets the current output buffer. |
void
|
setCookie(<String> key,<String> value,<Number> days,<String> path,<String> domain)
Sets a cookie to be sent to the client machine. |
void
|
stop()
Stops the execution of the request and sends the content of the reponse buffer. |
void
|
write(<String> text)
Writes a string to the output buffer. |
void
|
writeBinary(<Packages.java.ByteArray> data)
Writes binary data to the output buffer. |
void
|
writeln(<String> text)
Writes a string to the output buffer, adding a linebreak. |
| Properties Detail |
Boolean cache
res.cache = true
String charset
res.charset = "UTF8";
res.write("Ä Ö Ü ä ö ü ß");
// this is displayed if the brower's encoding is set to "Western"
à „ à – à œ à ¤ à ¶ à ¼ à Ÿ
String contentType
res.contentType='text/plain'; res.contentType='application/xhtml+xml';
Object data
File root/main.skin:
<html>
<head>
<title><% response.title %></title>
</head>
<body>
<% response.body %>
</body>
</html>
File root/main.hac:
res.data.title = "Test";
res.data.body = "Hello, World!";
root.renderSkin("main");
<html>
<head>
<title>Test</title>
</head>
<body>
Hello, World!
</body>
</html>
String error
res.write(res.error);
Runtime error Syntax error detected near line 1, column 24, after in string starting
with: 'function main_action (arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) {'...
String etag
Object handlers
Date lastModified
//in this example this.modificationDate is a property storing //the time of the last changes to the current object res.lastModified = this.modificationDate;
String message
File main.skin:
<% response.message %>
File main.hac:
res.message = "Hello, World!";
res.data.message = "Test";
this.renderSkin("main");
Hello, World!
Object meta
Inside an onRequest handler function: res.meta.permissions = this.doSomething(); Inside an action such as delete.hac: if(res.meta.permissions | 7) this.remove();
String realm
res.status = 401; res.realm = "Helma protected area";
HttpServletResponse servletResponse
res.servletResponse.setHeader( "Content-Disposition", ( this.mimetype.startsWith( "image/" )? "" : "attachment;" ) + "filename=\"" + this.name + "\"" );
Array skinpath
Number status
res.status = 401; //make sure to set res.realm as well when asking for http authentication res.realm = "Helma protected area";
| Method Detail |
void abort()
void commit()
for (var i in collection1) collection1.get(i).counter += 1; // commit changes to elements of collection1 to db res.commit(); for (var i in collection2) collection2.get(i).counter -= 1; // changes to elements of collection2 are committed // automatically when the request terminates
void debug(<String> text)
var now = new Date();
res.debug("current time: " + now);
current time: Tue May 20 18:59:02 CEST 2003
text - as String
void dependsOn(<String> what)
what - as string, an item this response depends on
void digest()
void encode(<String> textToEncode)
res.encode("<b>Bananer växer\n minsann inte på träd.</b>");
<b>Bananer växer
<br /> <br> minsann inte på träd.</b>
textToEncode - as String
void encodeXml(<String> textToEncode)
res.encodeXml("<title>Smørebrød</title>");
<title>Smørebr&oslash;d</title>
textToEncode - as String
void format(<String> textToFormat)
res.format("<table>\n<tr><td>Bananer växer\n minsann
inte på träd.</td></tr>\n</table>");
<table>
<tr><td>Bananer växer
<br />
minsann inte på träd.</td></tr>
</table>
textToFormat - as String
void forward(<String> path)
path - as String, relative to this app's protectedStatic directory
String getBuffer()
String pop()
res.push();
res.write("foo");
res.encode('.');
res.write("bar");
var str = res.pop()
// str is "foo.bar"
StringBuffer popBuffer()
void push()
res.push();
res.write("foo");
res.encode('.');
res.write("bar");
var str = res.pop();
// str is "foo.bar"
void pushBuffer(<StringBuffer> strBuffer)
strBuffer - as StringBuffer Java object, the StringBuffer to be pushed to the reponse object
void redirect()
res.redirect(this.href());
void reset()
res.write("Test");
// changing my mind (e.g. an error occured)
res.reset();
res.write("Hello, World!");
Hello, World!
void setCookie(<String> key,<String> value,<Number> days,<String> path,<String> domain)
res.setCookie("username", "michi");
res.setCookie("password", "strenggeheim", 10, "/mypath", ".mydomain.org");
key - as String
value - as String
days - as Number
path - as String
domain - as String
void stop()
function onRequest() {
if (fooIsCached()) {
res.write(fooFromCache());
res.stop();
}
}
void write(<String> text)
var now = new Date();
res.write("current time: " + now);
current time: Thu Feb 15 23:34:29 GMT+01:00 2001
text - as String
void writeBinary(<Packages.java.ByteArray> data)
var upload = req.data.fileUpload; res.writeBinary(upload.getContent());
data - as Packages.java.ByteArray
void writeln(<String> text)
var now = new Date();
res.writeln("current time:");
res.writeln(now);
current time:
Thu Feb 15 23:34:29 GMT+01:00 2001
text - as String
| SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods |