Class HistoryFilter
HistoryFilter
is both a Handler
and a
Filter
that keeps a record of all pages visited by a
given session.
The HistoryFilter
can be used to
make a user's session "mobile" as follows: A user's history
is normally stored with the browser being used, on the user's machine.
If the user runs a different browser or goes to a different machine, the
user's history will not be there. Instead, the user can access the web
via a proxy that keeps track of their history. No matter which browser
the user chooses or machine the user is at, a server running with the
HistoryFilter
will automatically remember and be able to
present the user's history.
The history is kept with respect to a Session ID.
This filter uses the following configuration properties:
-
prefix
- This handler will only process URLs beginning with this string. The default value is "", which matches all URLs.
-
session
- The name of the request property that holds the Session ID. The default value is "SessionID".
-
nosession
- The Session ID to use if the Session ID was not specified. The default value is "common".
-
admin
- URLs beginning with this prefix cause the
HistoryFilter
to store the history information for the current Session in the request properties -
filter
- If specified, then this is a
Regexp
pattern to match against the "Content-Type" of the result. Setting this also implies that theHistoryFilter
will be invoked as aFilter
and not aHandler
. The default value is "", which indicates that the "Content-Type" is not examined and that thisHistoryFilter
will be invoked as aHandler
.
- Version:
- 2.2
- Author:
- Colin Stevens (colin.stevens@sun.com)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
filter
(Request request, MimeHeaders headers, byte[] content) Returns the original content, since this filter does not change content.boolean
Initializes this filter by reading all its configuration properties.boolean
If theadmin
prefix is seen, store the history information associated with the session in the request properties.boolean
shouldFilter
(Request request, MimeHeaders headers) Called when invoked as aFilter
.
-
Field Details
-
urlPrefix
-
session
-
nosession
-
admin
-
filter
-
-
Constructor Details
-
HistoryFilter
public HistoryFilter()
-
-
Method Details
-
init
Initializes this filter by reading all its configuration properties.It is an error if the
filter
is specified but malformed. -
respond
If theadmin
prefix is seen, store the history information associated with the session in the request properties.If invoked as a
Handler
and the URL matches theprefix
, records this page's address in the history. -
shouldFilter
Called when invoked as aFilter
. If the URL matches theprefix
and the returned "Content-Type" matches thefilter
, records this page's address in the history.- Specified by:
shouldFilter
in interfaceFilter
- Parameters:
request
- The in-progress HTTP request.headers
- The MIME headers from the result.- Returns:
false
indicating that thisFilter
does not want to modify the content.
-
filter
Returns the original content, since this filter does not change content. Won't actually be invoked.- Specified by:
filter
in interfaceFilter
- Parameters:
request
- The finished HTTP request.headers
- The MIME headers generated by theHandler
.content
- The output from theHandler
that thisFilter
may rewrite.- Returns:
- The rewritten content. The
Filter
may return the originalcontent
unchanged. TheFilter
may returnnull
to indicate that theFilterHandler
should stop processing the request and should not return any content to the client.
-