Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

servlet api update #127

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/main/antora/modules/web/pages/servlets/servlets009.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,24 @@ The identifier can be maintained on the client as a cookie, or the web component
If your application uses session objects, you must ensure that session tracking is enabled by having the application rewrite URLs whenever the client turns off cookies.
You do this by calling the response's `encodeURL(URL)` method on all URLs returned by a servlet.
This method includes the session ID in the URL only if cookies are disabled; otherwise, the method returns the URL unchanged.

=== Servlet Request Connection Information

The session tracking as described above is sufficient for most applications but debugging and certain advanced use cases may require tracking individual low level connections.

New in the Servlet 6.0 API release is the `jakarta.servlet.ServletConnection` interface which gives fine-grained information about the connection associated with a given servlet request. Most notably `getConnectionId()` returns a unique ID for the network connection and `getRequestId()` returns a unique ID for the given servlet request.

Here is an example of retrieving the connection ID inside a servlet method:

[source,java]
----
@Override
public void doGet
(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
ServletConnection connection = request.getServletConnection();
String id = connection.getConnectionId();
...
}
----
9 changes: 8 additions & 1 deletion src/main/antora/modules/web/pages/servlets/servlets018.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
== Further Information about Jakarta Servlet Technology

For more information on Jakarta Servlet technology, see the Jakarta Servlet 5.0 specification at https://jakarta.ee/specifications/servlet/5.0/[^].
For more information on Jakarta Servlet technology, see the Jakarta Servlet 6.0 specification at https://jakarta.ee/specifications/servlet/6.0/[^].

The Jakarta Servlet 6.0 specification was released with Jakarta EE 10. For more about the changes in this release please see
https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Top-5-things-to-know-about-the-Jakarta-Servlet-60-API-release[this article^].

NOTE: As part of the Servlet 6.0 specification several deprecated methods and classes were permanently removed, please see the list here:
https://jakarta.ee/specifications/servlet/5.0/apidocs/deprecated-list.html[^].