4.3.5. JSP integration

If you add JSP pages to the Docmenta web application, you will most likely need access to the Plug-in API from within your JSP page. For this a static method org.docma.plugin.web.WebPluginUtil.getUserSession() exists, which requires a javax.servlet.ServletContext instance and the user's session ID as parameters. Following listing shows a minimal JSP page that just outputs the user's login name:
10 
11 
12 
13 
<%@page contentType="text/html" pageEncoding="UTF-8" session="true"
import="org.docma.plugin.*,org.docma.plugin.web.*"
%><%
// Note: application is an implicit JSP object (ServletContext)
String sessId = request.getParameter("docsess");
WebUserSession sess =
WebPluginUtil.getUserSession(application, sessId);
%>
<html>
<body>
Your login name: <%= sess.getUser().getLoginId() %>
</body>
</html>

Listing 4.3.21. Minimal JSP integration example

Note that the JSP page has to be called with the URL parameter named "docsess", which has to be set to the session ID as returned by the org.docma.plugin.web.WebUserSession.getSessionId() method. For an example on opening a JSP page in a new browser window, see Section 4.3.3.1, “Plain JavaScript Dialogs”.