REST Logout for WLP with JSP 2.0 EL

I used to create the log out URL like this:

String    webAppName    = request.getRequestURI().substring(1);
String    webAppPath    = request.getRequestURL().substring(0, request.getRequestURL().indexOf(webAppName));
String    restLogout    = webAppPath+webAppName.substring(0, webAppName.indexOf(‘/’))+”/bea/wlp/api/logout?invalidate_session=true”;

Then, today I needed to have it in a Bighorn skeleton, so I came up with the following:

<c:set var=”webAppName” value=”${fn:substring(pageContext.request.requestURI, 1, fn:length(pageContext.request.requestURI))}” scope=”application” />
<c:set var=”webAppPath” value=”${fn:substring(pageContext.request.requestURL, 0, fn:indexOf(pageContext.request.requestURL, webAppName))}” scope=”application” />
<c:set var=”restLogout” value=”${webAppPath}${fn:substring(webAppName, 0, fn:indexOf(webAppName, ‘/’))}/bea/wlp/api/logout?invalidate_session=true” scope=”application” />

With the URL in hand, you can now make the logout call:

function portalLogOut(restURL)
{
var xmlhttp    = null;
if (window.XMLHttpRequest)// code for IE7, Firefox, Mozilla, etc.
{
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)// code for IE5, IE6
{
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}

if(xmlhttp.overrideMimeType)xmlhttp.overrideMimeType(‘text/xml’);
if (xmlhttp!=null)
{
xmlhttp.open(“POST”,restURL,true);
xmlhttp.send(null);
}
}

Facebooktwitterredditlinkedinmail
© Scott S. Nelson

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.