This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/11.0.x by this push:
     new f2223e2509 Document the runtime attributes available to web 
applications.
f2223e2509 is described below

commit f2223e2509cf0dbf7320ee3134e1a4e1fc7db74c
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Mar 26 08:32:11 2025 +0000

    Document the runtime attributes available to web applications.
    
    Based on #832 by usmazat.
---
 webapps/docs/changelog.xml                 |   5 +
 webapps/docs/config/context.xml            |   8 +-
 webapps/docs/config/project.xml            |   1 +
 webapps/docs/config/runtime-attributes.xml | 180 +++++++++++++++++++++++++++++
 4 files changed, 193 insertions(+), 1 deletion(-)

diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index de0a9ca6fc..042e9c82b5 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -192,6 +192,11 @@
         Documentation. Add a link to the Log4j documentation that describes how
         to use Log4j rather than JULI for Tomcat's internal logging. (markt)
       </add>
+      <add>
+        Documentation. Document the runtime attributes available to web
+        applications via the Request or the ServletContext. Based on pull
+        request <pr>832</pr> by usmazat. (markt)
+      </add>
     </changelog>
   </subsection>
   <subsection name="Other">
diff --git a/webapps/docs/config/context.xml b/webapps/docs/config/context.xml
index a2fad26af6..99100f684e 100644
--- a/webapps/docs/config/context.xml
+++ b/webapps/docs/config/context.xml
@@ -175,7 +175,13 @@
   recommended that zero padding is used so that <code>foo##002.war</code> is
   treated as an earlier version than <code>foo##011.war</code>.
   </p>
-
+  <p>To get the current webapp version number in a servlet you should use
+  <code>org.apache.catalina.webappVersion</code>
+  <a href="runtime-attributes.html">attribute</a>, like this:
+  <code>String webappVersion =
+  
(String)request.getServletContext().getAttribute("org.apache.catalina.webappVersion");
+  </code>
+  </p>
   <p>If you want to deploy a WAR file or a directory using a context path that
   is not related to the base file name then one of the following options must
   be used to prevent double-deployment:
diff --git a/webapps/docs/config/project.xml b/webapps/docs/config/project.xml
index 2ad249bb2d..802a60f88f 100644
--- a/webapps/docs/config/project.xml
+++ b/webapps/docs/config/project.xml
@@ -89,6 +89,7 @@
     </menu>
 
     <menu name="Other">
+        <item name="Runtime attributes"    href="runtime-attributes.html"/>
         <item name="System properties"     href="systemprops.html"/>
         <item name="Jakarta Authentication"
               href="jaspic.html"/>
diff --git a/webapps/docs/config/runtime-attributes.xml 
b/webapps/docs/config/runtime-attributes.xml
new file mode 100644
index 0000000000..4c3ab79adb
--- /dev/null
+++ b/webapps/docs/config/runtime-attributes.xml
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!DOCTYPE document [
+  <!ENTITY project SYSTEM "project.xml">
+]>
+<document url="runtime-attributes.html">
+
+  &project;
+
+  <properties>
+    <title>Runtime attributes</title>
+  </properties>
+
+<body>
+
+<section name="Table of Contents">
+<toc/>
+</section>
+
+
+<section name="Introduction">
+  <p>The following attributes are made available to web applications at 
runtime.
+  Many of these attributes provide access to Tomcat internals. Attributes that
+  expose Tomcat internals may be explicitly requested by name but are often
+  deliberately not included when requesting a list of available attributes.</p>
+</section>
+
+<section name="Request attributes">
+  <p>Request attributes are made available to web applications via a call to
+  <code>ServletRequest.getAttribute(String)</code>.</p>
+  <properties>
+    <property name="jakarta.servlet.request.cipher_suite">
+      <p>The Servlet specification defined attribute for the name of the cipher
+      suite being used on an SSL connection.</p>
+    </property>
+    <property name="jakarta.servlet.request.key_size">
+      <p>The Servlet specification defined attribute for the key size being 
used
+      on an SSL connection.</p>
+    </property>
+    <property name="jakarta.servlet.request.secure_protocol">
+      <p>The Servlet specification defined attribute for the name of the
+      security protocol (e.g. TLSv1.3) being used on a secured connection.</p>
+    </property>
+    <property name="jakarta.servlet.request.ssl_session_id">
+      <p>The Servlet specification defined attribute for the session ID being
+      used for an SSL connection.</p>
+    </property>
+    <property name="jakarta.servlet.request.ssl_session_mgr">
+      <p>A Tomcat specific extension to the Servlet specification that provides
+      the session manager being used for an SSL connection.</p>
+    </property>
+    <property name="jakarta.servlet.request.X509Certificate">
+      <p>The Servlet specification defined attribute for the array of
+      X509Certificate objects representing the certificate chain presented by
+      our client, if any.</p>
+    </property>
+    <property name="org.apache.catalina.ASYNC_SUPPORTED">
+      <p>Does the processing chain (Servlet, Filters, Valves) for the current
+      request support asynchronous processing? Each component in the chain must
+      support asynchronous processing for this to be <code>true</code>.</p>
+    </property>
+    <property name="org.apache.catalina.NAMED">
+      <p>The name of the target Servlet for the current named dispatch, if
+      any.</p>
+    </property>
+    <property name="org.apache.catalina.core.DISPATCHER_TYPE">
+      <p>The current <code>jakarta.servlet.DispatcherType</code> for the
+      request.</p>
+    </property>
+    <property name="org.apache.catalina.core.DISPATCHER_REQUEST_PATH">
+      <p>The current path (Servlet Info + Path Info) to which the request has
+      been dispatched.</p>
+    </property>
+    <property name="org.apache.catalina.filters.RemoteIpFilter.secure">
+      <p>The request attribute that is set to the value of
+      <code>Boolean.TRUE</code> if the RemoteIpFilter determines that this
+      request was submitted via a secure channel.</p>
+    </property>
+    <property name="org.apache.catalina.realm.GSS_CREDENTIAL">
+      <p>The GSS credential for the currently authenticated user if they have
+      successfully authenticated using SPNEGO authentication.</p>
+    </property>
+    <property name="org.apache.tomcat.peerAddr">
+      <p>The request attribute set by the RemoteIpFilter, RemoteIpValve (and 
may
+      be set by other similar components) that identifies the connection peer 
IP
+      address.</p>
+    </property>
+    <property name="org.apache.tomcat.remoteAddr">
+      <p>The request attribute set by the RemoteIpFilter, RemoteIpValve (and 
may
+      be set by other similar components) that identifies for the connector the
+      remote IP address claimed to be associated with this request when a
+      request is received via one or more proxies. It is typically provided via
+      the X-Forwarded-For HTTP header.</p>
+    </property>
+    <property name="org.apache.tomcat.request.forwarded">
+      <p>The request attribute that is set to the value of
+      <code>Boolean.TRUE</code> by the RemoteIpFilter, RemoteIpValve (and other
+      similar components) that identifies a request which been forwarded via 
one
+      or more proxies.</p>
+    </property>
+    <property name="org.apache.tomcat.sendfile.end">
+      <p>The request attribute that can be used by a servlet to pass to the
+      connector the end offset (not included) of the part of a file that is to
+      be served by sendfile. The value should be <code>Long</code>. To serve 
the
+      complete file the value should be equal to the length of the file.</p>
+    </property>
+    <property name="org.apache.tomcat.sendfile.filename">
+      <p>The request attribute that can be used by a servlet to pass to the
+      connector the name of the file that is to be served by sendfile. The 
value
+      should be a <code>String</code> that is the canonical path of the file to
+      be served.</p>
+    </property>
+    <property name="org.apache.tomcat.sendfile.start">
+      <p>The request attribute that can be used by a servlet to pass to the
+      connector the start offset of the part of a file that is to be served by
+      sendfile. The value should be a <code>Long</code>. To serve the complete
+      file the value should be <code>Long.valueOf(0)</code>.</p>
+    </property>
+    <property name="org.apache.tomcat.sendfile.support">
+      <p>The request attribute that is set to the value of
+      <code>Boolean.TRUE</code> if connector processing this request supports
+      the use of sendfile.</p>
+    </property>
+  </properties>
+</section>
+
+<section name="ServletContext attributes">
+  <p>ServletContext attributes are made available to web applications via a 
call
+  to <code>ServletContext.getAttribute(String)</code>.</p>
+  <properties>
+    <property name="org.apache.catalina.CredentialHandler">
+      <p>The CredentialHandler (if any) associated with the Realm (if any)
+      that has been explicitly associated with the Context. Realms associated
+      with parent containers (Hosts or Engines) are not considered.</p>
+    </property>
+    <property name="org.apache.catalina.deploy.alt_dd">
+      <p>The alternate deployment descriptor for this web application.</p>
+    </property>
+    <property name="org.apache.catalina.jsp_classpath">
+      <p>The class path for our application class loader (as an object of type
+      String), delimited with the appropriate path delimiter for the
+      platform.</p>
+    </property>
+    <property name="org.apache.catalina.resources">
+      <p>The WebResourceRoot which is associated with the context.</p>
+    </property>
+    <property name="org.apache.catalina.webappVersion">
+      <p>The web application version string (the text that appears after ##
+      when parallel deployment is configured).</p>
+    </property>
+    <property name="org.apache.tomcat.InstanceManager">
+      <p>The InstanceManager used to create Servlets, Filters, Listeners etc.
+      for the web application.</p>
+    </property>
+    <property name="org.apache.tomcat.JarScanner">
+      <p>The JarScanner instance used to scan the web application for
+      annotations, TLDs, web fragments and similar features.</p>
+    </property>
+    <property 
name="org.apache.tomcat.util.threads.ScheduledThreadPoolExecutor">
+      <p>The utility executor for this Context.</p>
+    </property>
+  </properties>
+</section>
+</body>
+</document>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to