One of the most commonly asked questions in the portal forums is how to see who is logged on to a portal. While I'm not completely sure why people want to know this, I decided to try and put together a tool to help. ");
out.close();
File uFile = new File("
temp
user_"+from);
BufferedWriter o1 = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(uFile,false), "UTF8"));
o1.write(L.toString());
o1.close();
} catch (Exception e) {};
}
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
{
}
}
A bit of testing of the component by POSTing from a static HTML form seems to do the trick, so it's now time to replace the runtime version of the current SessionManager.jsp. This is done as a portal admin by restarting the com.sap.netweaver.coll.appl.ui.rtc archive: System admin -> Support -> Portal Runtime -> Application Console Find com.sap.netweaver.coll.appl.ui.rtc And then restart.
Now we need a quick portal component to report on files in \temp with a last stored date within the last 10 seconds and I have a component for listing currently logged on users:
package com.sap.anz;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.Date;
import com.sapportals.portal.prt.component.AbstractPortalComponent;
import com.sapportals.portal.prt.component.IPortalComponentRequest;
import com.sapportals.portal.prt.component.IPortalComponentResponse;
public class List extends AbstractPortalComponent
{
public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
{
response.write("h2. Currently logged on users
");
Date now = new Date();
long l = now.getTime();
try {
File dir = new File("
temp");
File[] fs = dir.listFiles();
for( int i = 0, ii = fs.length; i < ii; i++ ) {
String thisone = fs[i].getName();
if (thisone.startsWith("user_")) {
File f = new File("
temp
"+thisone);
BufferedReader i1 = new BufferedReader(new FileReader(f));
String line = i1.readLine();
i1.close();
long diff = l - new Long(line).longValue();
if (diff < 10000) // seconds * 1000
response.write("
"+thisone.substring(5));
}
}
} catch (Exception e) {
}
}
}