public class IlvServletPageIdUtil extends Object
This class provides utility methods used to support multiple pages per session (multiple tabs in a browser) on a Servlet context.
Since browsers do not properly identify tabs, JViews JSF cannot
distinguish requests coming from different tabs in the same browser.
This problem is solved by storing a unique identifier on each page
using WebStorage (window.sessionStorage
) so that
each tab has its own identifier.
Modifier and Type | Field and Description |
---|---|
static String |
PAGE_ID
The
page identifier used to identify a page in a
session. |
Modifier and Type | Method and Description |
---|---|
static String |
getPageId(jakarta.servlet.http.HttpServletRequest request)
This method returns the page identified stored in the given
request.
|
static Object |
getSessionAttributeWithPageId(jakarta.servlet.http.HttpServletRequest request,
String name)
Retrieves an object from this session using a page identifier.
|
static String |
setSessionAttributeWithPageId(jakarta.servlet.http.HttpServletRequest request,
String name,
Object value)
Stores a given object in this session using a page identifier.
|
public static final String PAGE_ID
page identifier
used to identify a page in a
session. This allows support for multiple browser tabs.public static String getPageId(jakarta.servlet.http.HttpServletRequest request)
This method returns the page identified stored in the given request. If no identifier is found, a new one is created and added to the request.
Its simple implementation is based on a sequential int
counter that is limited to 2,147,483,647. It is unlikely that the
application will ever reach this value, and even if it does, it is
unlikely that the repeating identifiers will be assigned to the same
session.
request
- The HttpServletRequest
where the
pageId is stored.public static String setSessionAttributeWithPageId(jakarta.servlet.http.HttpServletRequest request, String name, Object value)
Stores a given object in this session using a page identifier.
The page identifier is combined to the given name
to
form a unique identifier that is only known to the page originating
the request. This allows for multiple browser tab support, as the
page in a browser tab will not share this object with the same page
opened in a different tab.
If the session does not exist, a new one will be created; if an object is already bound to this unique identifier, it will be replaced; if a page identifier does not exist for this session, a new one will be created.
request
- The request where the name/object binding should be stored.name
- The original attribute name to be combined with the
page identifier. It cannot be null
.value
- The object being bound to the attribute name.name
parameter with the
page identifier.public static Object getSessionAttributeWithPageId(jakarta.servlet.http.HttpServletRequest request, String name)
Retrieves an object from this session using a page identifier.
The name
parameter is combined with the page identifier
to form the attribute name used to retrieve the object.
request
- The request where the name/object binding should be stored.name
- The original attribute name to be combined with the
page identifier. It cannot be null
.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.