Skip to content

Instantly share code, notes, and snippets.

View nuwanbando's full-sized avatar

Nuwan Bandara nuwanbando

View GitHub Profile
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sample Jaggery web application</title>
</head>
<body>
<%@ taglib uri="http://wso2.org/jaggery/bsftags" prefix="js" %>
@nuwanbando
nuwanbando / HelloWorld.jssp
Created December 20, 2011 11:38
Jaggery Script
<html>
<head>
<title>Sample Jaggery web application</title>
</head>
<body>
<%@ taglib uri="http://wso2.org/jaggery/bsftags" prefix="js" %>
<js:script>
var s = "";
for(var i=0;i<9;i++){
for(var j=0;j<=i;j++){
<html>
<head>
<title>Sample Jaggery web application</title>
</head>
<body>
<%@ taglib uri="http://wso2.org/jaggery/bsftags" prefix="js" %>
<js:script>
var s = "";
for(var i=0;i<9;i++){
for(var j=0;j<=i;j++){
@nuwanbando
nuwanbando / HelloWorld.jss
Created December 21, 2011 17:06
Say Hello To Jaggery
function doGet(request, response, session) {
var name = request.getParameter("myName");
response.write("Hello " + name);
}
├── controllers
│   ├── atom.jss
│   ├── email.jss
│   ├── file.jss
│   ├── fileupload.jss
│   ├── json.jss
│   ├── rdb.jss
│   ├── registry.jss
│   ├── request.jss
│   ├── response.jss
@nuwanbando
nuwanbando / json.jss
Created December 21, 2011 18:17
JSON Sample
function doGet(request, response, session) {
return {
name : "Jhon",
age : "25",
address : {
number : "23",
address1 : "Flower Rd",
address2 : "Colombo 07",
city : "Colombo"
}
@nuwanbando
nuwanbando / request.jss
Created December 21, 2011 18:28
Request Sample
function doGet(request, response, session) {
response.write("<html><body>");
response.write("Method : " + request.method + "<br/>");
response.write("Protocol : " + request.protocol + "<br/>");
response.write("User-Agent : " + request.getHeader("User-Agent"));
response.write("</body></html>");
}
/**
XMLHttpRequest API is same as which can be found in browser environment.
**/
function doGet(request, response, session) {
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.google.lk");
xhr.send();
response.write(xhr.responseText);
}
function doGet(request, response, session) {
//LOCAL_REPOSITORY, SYSTEM_GOVERNANCE, SYSTEM_CONFIGURATION, USER_GOVERNANCE, USER_CONFIGURATION
var registry = new Registry("SYSTEM_CONFIGURATION");
var resource = registry.newResource();
resource.content = '<products><product name="Mashup Server"/><product name="Gadget Server"/></products>';
resource.addProperty("url", "http://wso2.com");
resource.addProperty("company", "WSO2 Inc.");
registry.put("wso2products.xml", resource);
//now we read the resource again
function doGet(request, response, session) {
var db = new RDB("mysql", "localhost", "3306", "myDB", "root", "root");
db.query("SELECT * FROM myTable", function(results) {
var path = "/tmp/";
var file = new File(path + "rdbTest.txt");
if(!file.exists) file.createFile();
file.openForAppending();
for(var i=0;i<results.length;i++) {
file.writeLine(results[i].myColumn);
}