Java EE 7 SDK |
This sample application demonstrates the programmatic configuration support for session cookies available in servlets.
This sample application declares a ServletContextListener in its deployment descriptor.
This ServletContextListener
configures, via the SessionCookieConfig interface,
various aspects of the application's cookies used for HTTP session tracking purposes.
This application has cookies enabled.
The client accesses the CreateSession servlet of the application, which creates an
HTTP session, retrieves the value of the corresponding Set-Cookie header from the response,
and ensures that it matches the configuration that was applied by the ServletContextListener
during the application's initialization phase.
This sample application demonstrates how to use the SessionCookieConfig
interface in
a ServletContextListener
to configure cookies for web applications.
Perform the following steps to build, deploy, and run the application:
app_dir
is the sample application base
directory: samples_install_dir/servlet/session-cookie-config-war
.
Change directory to app_dir.
mvn
target:
Use the command below to run this sample using the Cargo framework:
app_dir>
mvn clean verify cargo:run
You can point Cargo to an already installed and running Glassfish server:
app_dir> mvn clean verify cargo:run -Dglassfish.home=$<glassfish_dir>
(e.g. ../glassfish4)
You can also build, deploy the sample application without Cargo:
app_dir> mvn install
app_dir> asadmin deploy ./target/<app_name>.war
http://<javaee.server.name>:<javaee.server.port>/session-cookie-config-war
SUCCESS
app_dir>
asadmin undeploy
<app_name>
clean
to remove the temporary directories
like /target.
app_dir> mvn
clean
Perform the following steps to build, deploy, and run the application using NetBeans IDE:
samples_install_dir/servlet/
directory, select session-cookie-config-war
, and click Open Project.session-cookie-config-war
and select Run to build, deploy, and run the project.If you have problems when running the application, refer the troubleshooting document.
Copyright © 1997-2013 Oracle and/or its affiliates. All rights reserved.