Class HttpSessionAccess

java.lang.Object
org.eclnt.jsfserver.util.HttpSessionAccess
All Implemented Interfaces:
ICCServerConstants

public class HttpSessionAccess extends Object implements ICCServerConstants
Access to http request and context environment.
  • Constructor Details

    • HttpSessionAccess

      public HttpSessionAccess()
  • Method Details

    • initialize

      public static void initialize(javax.servlet.ServletContext servletContext)
    • getCurrentFacesContext

      public static javax.faces.context.FacesContext getCurrentFacesContext()
      Accessing the FacesContext. You should use this method instead of directly accessing FacesContext.getCurrentInstance() in case you pass the FacesContext into non-UI threads.
    • getCurrentFacesApplication

      public static javax.faces.application.Application getCurrentFacesApplication(javax.faces.context.FacesContext context)
      Accessing the Application. This method is already considering cases in which the application is accessed from a non-UI thread.
    • getCurrentELContext

      public static javax.el.ELContext getCurrentELContext(javax.faces.context.FacesContext context)
      Accessing the EL context which is for accessing expressions. This method is already considering cases in which the application is accessed from a non-UI thread.
    • getCurrentHttpSession

      public static javax.servlet.http.HttpSession getCurrentHttpSession()
      This session must only be called within the context of a request processing!

      Please pay attention: call function getCurrentDialogSession() if you want to access the session that is managed per browser tab instance! The http session may sapn several browser tabs - if using COOKIEs for session management!
    • getCurrentHttpSessionIfAvailable

      public static javax.servlet.http.HttpSession getCurrentHttpSessionIfAvailable(javax.faces.context.FacesContext context)
      Same as getCurrentHttpSession() - now with passing the FacesContext instance, which guides to the http session and now without creating the http session if it does not exist.

      Please pay attention: call function getCurrentDialogSession() if you want to access the session that is managed per browser tab instance! The http session may sapn several browser tabs - if using COOKIEs for session management!
    • getCurrentHttpSessionIfAvailable

      public static javax.servlet.http.HttpSession getCurrentHttpSessionIfAvailable(ISessionContextProvider context)
    • getCurrentHttpSession

      public static javax.servlet.http.HttpSession getCurrentHttpSession(javax.faces.context.FacesContext context)
      Same as getCurrentHttpSession() - now with passing the FacesContext instance, which guides to the http session.

      Please pay attention: call function getCurrentDialogSession() if you want to access the session that is managed per browser tab instance! The http session may sapn several browser tabs - if using COOKIEs for session management!
    • getCurrentHttpSession

      public static javax.servlet.http.HttpSession getCurrentHttpSession(ISessionContextProvider context)
    • getCurrentComponentDump

      public static ComponentDump getCurrentComponentDump(javax.faces.context.FacesContext context)
      Internal use only.
    • getCurrentComponentDump

      public static ComponentDump getCurrentComponentDump(ISessionContextProvider context)
    • getCurrentComponentDump

      public static ComponentDump getCurrentComponentDump(ISessionAbstraction httpSession, String subpageId)
      Internal use only.
    • addGlobalHttpSessionListener

      public static void addGlobalHttpSessionListener(IHttpSessionListener listener)
      Adds a listener for creation/closing of http session. THis listener is globally registered (i.e. "one time" per servlet context) and NOT registered per session.
    • removeGlobalHttpSessionListener

      public static void removeGlobalHttpSessionListener(IHttpSessionListener listener)
    • addHttpSessionCloseReactorForCurrentSession

      public static void addHttpSessionCloseReactorForCurrentSession(String id, IHttpSessionClosedReactor reactor)
      Adds a reactor interface into the current http session which notifies about closing the session. Pleas pay attention to the difference between http-session and dialog-session (URL- or COOKIE-based session management). If you want to get notified about the "per-browser-session" then use addDialogSessionClosedReactorForCurrentSession(ISessionAbstractionListener).
    • removeHttpSessionCloseReactorForCurrentSession

      public static void removeHttpSessionCloseReactorForCurrentSession(String id)
    • addGlobalDialogSessionListener

      public static void addGlobalDialogSessionListener(IDialogSessionListener listener)
    • removeGlobalDialogSessionListener

      public static void removeGlobalDialogSessionListener(IDialogSessionListener listener)
    • addDialogSessionClosedReactorForCurrentSession

      public static void addDialogSessionClosedReactorForCurrentSession(ISessionAbstractionListener listener)
      Adds a reactor interface into the current dialog session which notifies about closing the dialog session.
    • removeDialogSessionClosedReactorForCurrentSession

      public static void removeDialogSessionClosedReactorForCurrentSession(ISessionAbstractionListener listener)
    • getCurrentHttpSessionListenerDelegator

      public static HttpSessionListenerDelegator getCurrentHttpSessionListenerDelegator()
      Internal use.
    • getCurrentHttpSessionListenerDelegator

      public static HttpSessionListenerDelegator getCurrentHttpSessionListenerDelegator(javax.servlet.http.HttpSession session)
      Internal use.
    • getServletContext

      public static javax.servlet.ServletContext getServletContext()
      Return the servlet context that was passed by the Servlet-container.
    • getWebApplicationName

      public static String getWebApplicationName()
      Returns name of the deployed web application using its context path as base.

      The context path is a string like "/demos" - and is the URL prefix that is uniquely used for the web application within the servlet container. The name of the application is taken from the context path - without leading slash. In case the context path is the root context path ("/") then "root" is returned.

      During (JUnit) testing, the servlet context might not be available. Use UsageWithoutSessionContext to indicate that you are running in test mode - in this case "undefined" is returned.
    • getServletTempDirectory

      public static String getServletTempDirectory()
      A servlet context provides access to a temporary directory in which you can write or read data. Pay attention: in a clustered scenario the temp directory might be different from request to request - because the session might be migrated from one server to the next.
    • getServletTempDirectory

      public static String getServletTempDirectory(javax.servlet.ServletContext servletContext)
    • getCurrentClientTimeZoneOffset

      public static int getCurrentClientTimeZoneOffset()
      The browser client sends its time zone offset as part of the http communication. This method is the number of minutes that the browser's time zone is different to the GMT time.
    • getCurrentClientLocale

      public static Locale getCurrentClientLocale()
      This is the localization of the client! The client localization may be different to the server localization!

      The localization of the server can be accessed by method getCurrentLocale().
    • getCurrentRequest

      public static javax.servlet.http.HttpServletRequest getCurrentRequest()
      Returns the servlet request that triggered the current request processing. This functions is expected to be called as part of the default request/response processing.

      If called outside this processing, then null will be returned.
    • getCurrentLocationHref

      public static String getCurrentLocationHref()
      Returns the original URL that started the CaptainCasa page. This is the ".risc" page (or other extension if you customized accordingly).
      Returns:
      URL as String, null in case the URL cannot be found (e.g. if method is not called within the context of a request processing)
    • getCurrentResponse

      public static javax.servlet.http.HttpServletResponse getCurrentResponse()
      Returns the servlet response of the current request processing. This functions is expected to be called as part of the default request/response processing.

      If called outside this processing, then null will be returned.
    • setValueBindingListener

      public static void setValueBindingListener(IValueBindingListener vbl)
      Internal use only.
    • getValueBindingListener

      public static IValueBindingListener getValueBindingListener()
      Internal use only.
    • setMethodBindingListener

      public static void setMethodBindingListener(IMethodBindingListener mbl)
      Internal use only.
    • getMethodBindingListener

      public static IMethodBindingListener getMethodBindingListener()
      Internal use only.
    • checkIfInLayoutEditorPreview

      public static boolean checkIfInLayoutEditorPreview()
      Passes back information if the current dialog is opened in the preview mode of the editor. This method returns true only for the first request that is sent from the preview to the server side processing. Subsequent requests are always treated as "normal" requests. Please check the method checkIfDialogSessionInLayoutEditorPreview().
      Returns:
      "true" if opened in layout editor preview - for the first request
      "false" otherwise
    • checkIfDialogSessionInLayoutEditorPreview

      public static boolean checkIfDialogSessionInLayoutEditorPreview()
      Passes back information if the current dialog session is opened in the preview mode of the editor. Compared to method checkIfInLayoutEditorPreview() this method not only returns "true" for the first request of the dialog, but returns back "true" for all subsequent requests as well.
      Returns:
      "true" if opened in layout editor preview
      "false" otherwise
    • getCurrentRequestId

      public static String getCurrentRequestId()
      Each request is associated with a unique id when entering the server side processing.
    • checkIfCurrentHttpSessionWasDestroyedDuringInvokePhase

      public static boolean checkIfCurrentHttpSessionWasDestroyedDuringInvokePhase()
      During the invoke phase the application may destroy the current http session (by calling the http-session's invalidate() method. In this case follow on processing may react correspondingly.
    • checkIfCurrentHttpSessionWasDestroyedDuringInvokePhase

      public static boolean checkIfCurrentHttpSessionWasDestroyedDuringInvokePhase(javax.servlet.http.HttpSession session)
    • checkIfCurrentHttpSessionWasDestroyedDuringInvokePhase

      public static boolean checkIfCurrentHttpSessionWasDestroyedDuringInvokePhase(ISessionAbstraction session)
    • checkIfRunningInEmbeddedMode

      public static boolean checkIfRunningInEmbeddedMode()
      Checks if the current request processing is executed in an embedded usage (stand alone) environment.
    • checkIfRunningInMiniServerMode

      public static boolean checkIfRunningInMiniServerMode()
    • checkIfJustProcessingRequest

      public static boolean checkIfJustProcessingRequest()
    • checkIfCurrentSessionWasStartedByHttps

      public static boolean checkIfCurrentSessionWasStartedByHttps()
      Returns true if the client's original .risc-URL was started via https.
    • getCurrentClientType

      public static String getCurrentClientType()
      Passes back the client type that is used by the current user. Values that are returned are "applet", "webstart", "application", "browser"
    • getCurrentClientType

      public static String getCurrentClientType(javax.servlet.http.HttpServletRequest request)
      Passes back the client type that is used by the current user. Values that are returned are "applet", "webstart", "application", "browser". Use constans defined in ICCServerConstants for comparing the result values.
    • checkIfCurrentClientTypeIsUI5

      public static boolean checkIfCurrentClientTypeIsUI5(javax.servlet.http.HttpServletRequest request)
    • checkIfCurrentClientTypeIsRisc

      public static boolean checkIfCurrentClientTypeIsRisc()
    • checkIfCurrentClientTypeIsRisc

      public static boolean checkIfCurrentClientTypeIsRisc(javax.servlet.http.HttpServletRequest request)
    • checkIfCurrentClientTypeIsRisc

      public static boolean checkIfCurrentClientTypeIsRisc(javax.servlet.http.HttpSession session)
    • getCurrentClientJavaType

      public static String getCurrentClientJavaType()
      Information about the client's Java technology.
      Returns:
      either "swing" or "fx" or "risc"
    • getCurrentClientJavaType

      public static String getCurrentClientJavaType(javax.servlet.http.HttpServletRequest request)
      Returns back client java type that is transferred via the http header. Only passes back a value if the client is a Java client.
    • checkIfCurrentClientJavaTypeIsFX

      public static boolean checkIfCurrentClientJavaTypeIsFX()
      Check if current client is an FX client.
    • checkIfCurrentClientJavaTypeIsRisc

      @Deprecated public static boolean checkIfCurrentClientJavaTypeIsRisc()
      Deprecated.
      Check if current client is a RISC client. (This method is deprecated because of its name. A client that is of type Java cannot be a RISC client... - please use checkIfCurrentClientTypeIsRisc() instead.)
    • checkIfCurrentClientJavaTypeIsSwing

      public static boolean checkIfCurrentClientJavaTypeIsSwing()
      Check if current client is a Swing client.
    • getCurrentClientScreenPixelWidth

      public static int getCurrentClientScreenPixelWidth()
      Returns -1 if the screen width is not transferred from client side.
    • getCurrentClientScreenPixelHeight

      public static int getCurrentClientScreenPixelHeight()
      Returns -1 if the screen width is not transferred from client side.
    • getCurrentClientDeviceType

      public static String getCurrentClientDeviceType()
      Returns null if not transferred from client side.

      Current values: "desktop" and "mobile" (mobile being a synonym for non-desktop, i.e. phone/tablet)
    • getCurrentClientId

      public static String getCurrentClientId()
      Passes back an id that is associated with the client. The client id is some explicit id that identifies the client on a long term (or at least: longer than the life cycle of a session).

      In the RISC client the client id is stored as cookie. The client id is automaitcally generated if it does not exist yet. - You can epplicitly set the client id by using ServletUtil.writeEclntIdCookie(HttpServletResponse, String). Or you may set by using the html page: eclntjsfserver/utilpages/setclientid.html within your web application.
    • getCurrentClientId

      public static String getCurrentClientId(boolean createClientIdIfNotExists)
    • setCurrentClientId

      public static void setCurrentClientId(String clientId)
      Explicitly set the client id to some defined value.
    • getCurrentLocale

      public static Locale getCurrentLocale()
      Retrieve the Locale that is used on server side within the current session. In normal situations this is taken from the viewRoot of the FacesContext - but sometimes this function is also used outside a valid FacesContext (e.g. when downloading information). In this case the Locale is taken from the session context.

      In case there is no session available then the Locale of the server environment is returned.

      Pay attention: the localization of the client may be different! You get this localization by calling getCurrentClientLocale().
    • setCurrentLocale

      public static void setCurrentLocale(Locale l)
      Sets the locale that is passed as locale for the current session.
    • setCurrentStyle

      public static void setCurrentStyle(String style)
      Sets the current style for the session.
    • getCurrentStyle

      public static String getCurrentStyle()
      Returns the current style for the session.
    • reloadClient

      public static void reloadClient()
      Sends a signal to the client side that triggers a reload of the complete page - within the current session (i.e. no new session is created). This method is e.g. used when updating the style of the client - in this case all the server side components need to be re-created, which is exactly done through the reload.
    • reloadClient

      public static void reloadClient(javax.servlet.http.HttpServletResponse response)
    • getCurrentSubpageContext

      public static SubpageContext getCurrentSubpageContext()
      Access to the subpage context, which is available if one Http-session is shared across multiple browser instances - due to using cookies for session tracking.
    • getCurrentSubpageContext

      public static SubpageContext getCurrentSubpageContext(javax.servlet.http.HttpSession session)
      Access to the subpage context, which is available if one Http-session is shared across multiple browser instances - due to using cookies for session tracking.
    • getCurrentDialogSession

      public static ISessionAbstraction getCurrentDialogSession()
      The dialog session is the session that is associated with a dialog ("browser tab instance") on client side. In case of using URL-encoding for session management this is a wrapper around the http-session. In Cas of using COOKIEs for session management this is a wrapper around the subpage context.
    • getCurrentDialogSession

      public static ISessionAbstraction getCurrentDialogSession(javax.servlet.http.HttpSession session)
      The dialog session is the session that is associated with a dialog ("browser tab instance") on client side. In case of using URL-encoding for session management this is a wrapper around the http-session. In Cas of using COOKIEs for session management this is a wrapper around the subpage context.
    • getCurrentDialogSession

      public static ISessionAbstraction getCurrentDialogSession(javax.servlet.http.HttpSession session, String subpageId)
    • switchProfileModeOnForCurrentSession

      public static void switchProfileModeOnForCurrentSession()
      Switch profile mode on. In the profile mode performance data is written to the file system.
    • switchProfileModeOffForCurrentSession

      public static void switchProfileModeOffForCurrentSession()
      Switch profile mode off. In the profile mode performance data is written to the file system.
    • getInitialRequestParameters

      public static Map<String,String> getInitialRequestParameters()
      Request parameters that were passed with the initial request.
    • getClientDeviceInfos

      public static List<ClientDeviceInfo> getClientDeviceInfos(javax.servlet.http.HttpServletRequest postRequest)