{"id":431,"date":"2011-12-14T22:19:31","date_gmt":"2011-12-14T20:19:31","guid":{"rendered":"http:\/\/hasselba.ch\/blog\/?p=431"},"modified":"2011-12-14T22:20:20","modified_gmt":"2011-12-14T20:20:20","slug":"mit-ssjs-auf-die-http-session-zugreifen","status":"publish","type":"post","link":"https:\/\/hasselba.ch\/blog\/?p=431","title":{"rendered":"Quick-n-Dirty: Die HTTP-Session des Domino-Servers"},"content":{"rendered":"<p>Um mit SSJS auf die HTTP-Session eines Domino-Servers zuzugreifen, ist nicht viel Code n\u00f6tig:<\/p>\n<pre>var exCon = facesContext.getExternalContext();\r\nvar sess = exCon.getRequest().getSession();<\/pre>\n<p>Dadurch lassen sich folgende Informationen ermitteln:<\/p>\n<ul>\n<li><strong>getAttribute(Name:String)<\/strong><\/li>\n<\/ul>\n<p style=\"padding-left: 60px;\">Liefert gebundenes Objekt des Attributes &#8222;Name&#8220; zur\u00fcck<\/p>\n<ul>\n<li><strong>getAttributeNames()<\/strong><\/li>\n<\/ul>\n<p style=\"padding-left: 60px;\">Liefert die Namen aller Attribute als java.util.Enumeration zur\u00fcck.<\/p>\n<ul>\n<li><strong>getCreationTime()<\/strong><\/li>\n<\/ul>\n<p style=\"padding-left: 60px;\">Zeit der Session-Erstellung, Millisekunden seit 1.1.1970 GMT, z.B. &#8222;1.323785660873E12&#8220;<\/p>\n<ul>\n<li><strong>getId()<\/strong><\/li>\n<\/ul>\n<p style=\"padding-left: 60px;\">Liefert die aktuelle SessionID zur\u00fcck, z.B. &#8222;D18P2LFFB5&#8220;<\/p>\n<ul>\n<li><strong>getLastAccessedTime()<\/strong><\/li>\n<\/ul>\n<p style=\"padding-left: 60px;\">Zeit, an der die Session zuletzt aufgerufen wurde. In Millisekunden seit 1.1.1970 GMT, z.B. &#8222;1.323785660873E12&#8220;<\/p>\n<ul>\n<li><strong>getMaxInactiveInterval()<\/strong><\/li>\n<\/ul>\n<p style=\"padding-left: 60px;\"><strong><\/strong>L\u00e4nge der maximalen G\u00fcltigkeit einer Session (in Sekunden) , die vom Servlet ohne Clientaktivit\u00e4t abgewartet wird.<\/p>\n<ul>\n<li><strong>isNew()<\/strong><\/li>\n<\/ul>\n<p style=\"padding-left: 60px;\"><strong><\/strong><em>True<\/em>, wenn der Client die Sessio noch nicht kennt, <em>false<\/em> wenn der Client einer bestehende Session beitritt.<\/p>\n<ul>\n<li><strong>invalidate()<\/strong><\/li>\n<\/ul>\n<p style=\"padding-left: 60px;\"><strong><\/strong>Setzt eine Session zur\u00fcck und l\u00f6scht alle Daten der Session<\/p>\n<ul>\n<li><strong>removeAttribute(Name:String)<\/strong><\/li>\n<\/ul>\n<p style=\"padding-left: 60px;\">L\u00f6scht das Attribut &#8222;<em>Name<\/em>&#8220; und entfernt das gebundene Objekt<\/p>\n<ul>\n<li><strong>setAttribute(Name:String, obj:Object)<\/strong><\/li>\n<\/ul>\n<p style=\"padding-left: 60px;\">Setzt das Attribut &#8222;<em>Name<\/em>&#8220; mit dem Objekt &#8222;<em>obj<\/em>&#8222;.<\/p>\n<ul>\n<li><strong>setMaxInactiveInterval(int interval)<\/strong><\/li>\n<\/ul>\n<p style=\"padding-left: 60px;\">Setzt maximale L\u00e4nge der Session in Sekunden, bis das Servlet die Session ablaufen l\u00e4sst.<\/p>\n<p>&nbsp;<\/p>\n<p>Um die Attribute einer Session auszugeben, kann z.B. folgender Code verwendet werden:<\/p>\n<pre>var attr = sess.getAttributeNames();\r\nwhile( attr.hasMoreElements() ){\r\n   var elem = attr.nextElement();\r\n   result += elem + \" -&gt; \";\r\n   result += sess.getAttribute( elem );\r\n   result += \" [\";\r\n   result += typeof(sess.getAttribute( elem ));\r\n   result += \"]\";\r\n }\r\n\r\nresult<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Um mit SSJS auf die HTTP-Session eines Domino-Servers zuzugreifen, ist nicht viel Code n\u00f6tig: var exCon = facesContext.getExternalContext(); var sess = exCon.getRequest().getSession(); Dadurch lassen sich folgende Informationen ermitteln: getAttribute(Name:String) Liefert gebundenes Objekt des Attributes &#8222;Name&#8220; zur\u00fcck getAttributeNames() Liefert die Namen &hellip; <a href=\"https:\/\/hasselba.ch\/blog\/?p=431\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,89,82,76,74],"tags":[7,86,16,5,32,3],"class_list":["post-431","post","type-post","status-publish","format-standard","hentry","category-allgemein","category-java","category-server","category-ssjs","category-xpages","tag-domino","tag-jsf","tag-server","tag-ssjs","tag-tipp","tag-xpages"],"_links":{"self":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/431","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=431"}],"version-history":[{"count":7,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/431\/revisions"}],"predecessor-version":[{"id":438,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/431\/revisions\/438"}],"wp:attachment":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=431"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}