Skip to content

Instantly share code, notes, and snippets.

@andresbott
Created November 26, 2017 01:12
Show Gist options
  • Save andresbott/7344f22d1d6f9876287dbc03ac1081b0 to your computer and use it in GitHub Desktop.
Save andresbott/7344f22d1d6f9876287dbc03ac1081b0 to your computer and use it in GitHub Desktop.
apache sling ESP sample
<% sling.include("/apps/fileshare/content/header"); %>
<div class="container">
<div class="row">
<div class="col-sm-6 col-md-4 col-md-offset-4">
<h1 class="text-center login-title">This will show a fileLink</h1>
<div class="account-wall">
</div>
</div>
</div>
<%
var app =
{sling: sling,
request: request,
response: response,
resourceResolver: request.getResourceResolver(),
resource: resource,
pathInfo: request.getRequestPathInfo()
};
var server = request.scheme+ "://"+ request.serverName + ":"+ request.serverPort
%>
<%= typeof Suffix %>
<br>
<span> Sufix : <%= Suffix %></span>
<br>
<span> server : <%= server %></span>
<%= app.request.getRequest %>
<br>
<table>
<% var j = 0;
var s = "";
for (var i in app.request ) { %>
<tr>
<td>
<%= j %>:
</td>
<td>
<%= i %>
</td>
<td>
<%
if( i == "getServerName"){
var s = request.getServerName();
}
if( i == "getParameter"){
s = "sample url parameter id =";
s += app.request.getParameter("id");
}
if( i == "getRequestURL"){
var s = request.getRequestURL();
}
if( i == "method"){
var s = request.method;
}
if( i == "scheme"){
var s = request.scheme;
}
if( i == "getRequest"){
var s = request.getRequest();
}
if( i == "serverName"){
var s = request.serverName;
}
if( i == "serverPort"){
var s = request.serverPort;
}
if( i == "suffix"){
var s = app.pathInfo.suffix;
}
if( i == "getHeaders"){
var c = request.getHeaders("User-Agent");
while ( c.hasMoreElements() )
s += c.nextElement();
}
%>
<%= s %>
</td>
</tr>
<%
j++;
s = "";
} %>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment