Hi Bertin,
indeed i would re-use those services whenever possible.
Html 5 Webpages exist with or without back-end servlet/jsp/php,...
A) Page with server side php/jsp/..:
Simply call the Scout Service using a Scout Transaction. Therefore you Need a Scout Server session for that user as well as a security subject (javax.security).
The session can be obtained in the same way as the Scout servlet
does it.
private IServerSession lookupScoutServerSessionOnHttpSession(HttpServletRequest req, HttpServletResponse res, Subject subject, UserAgent userAgent) throws ProcessingException, ServletException {
//external request: apply locking, this is the session initialization phase
synchronized (req.getSession()) {
IServerSession serverSession = (IServerSession) req.getSession().getAttribute(IServerSession.class.getName());
if (serverSession == null) {
serverSession = SERVICES.getService(IServerSessionRegistryService.class).newServerSession(m_serverSessionClass, subject, userAgent);
req.getSession().setAttribute(IServerSession.class.getName(), serverSession);
}
return serverSession;
}
}
The subject can be used either from the webcontainer itself (WLS)
Subject subject = Subject.getSubject(AccessController.getContext());
or by creating one
Subject subject=new Subject();
subject.getPrincipals().add(new org.eclipse.scout.commons.security.SimplePrincipal(...));
Finally simply use
new ServerJob("web",session, subject){
protected IStatus runTransaction(IProgressMonitor monitor){
//your code goes here, you can use HttpServletRequest, HttpServletResponse etc. as well
SERVICES.getService(...).doWhatever();
}
}
B) Page without server side php/jsp/..:
In this case i would create a subclass of and override and .
There detect your Webpage request for example by using an additional URL path or a URL Parameter. Then it continues similar to A).
B2) You may also write a complete new servlet and using the concepts in A) Server Ajax Clients with exactly the protocol you Need, for example json.
Does this help?