- All Implemented Interfaces:
Servlet,ServletConfig,Serializable
We choose MD5 over SHA-256 because Jenkins uses MD5 for fingerprints. This allows to directly search and find exactly which build deployed the running application.
Find the WAR file based on the path the application is deployed to.
Uses ServletContext.getRealPath("/")
then appends ".war". This might be specific to Tomcat installations, and should
not be assumed to apply generally.
- See Also:
-
Field Summary
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoGet(HttpServletRequest request, HttpServletResponse response) getWarFileFingerprint(ServletContext context) Computes the MD5 sum of the WAR file, located by usingServletContext.getRealPath("/")concatenated withWAR_EXTENSION.voidinit(ServletConfig config) Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, serviceMethods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Constructor Details
-
GetWarFileFingerprint
public GetWarFileFingerprint()
-
-
Method Details
-
getWarFileFingerprint
Computes the MD5 sum of the WAR file, located by usingServletContext.getRealPath("/")concatenated withWAR_EXTENSION.If unable to find or compute, the specific reason is logged with level
Level.WARNINGorLevel.SEVERE, depending on the nature of the failure. This method is not expected to be used frequently, only after deployments and possibly via occasional audit / monitoring. Logging of these messages is considered best from a security standpoint and are not expected to fill storage space significantly.- Returns:
- The non-empty string of the WAR file fingerprint or
Optional.empty()when unable to compute the fingerprint (in which case the underlying cause is logged).
-
init
- Specified by:
initin interfaceServlet- Overrides:
initin classHttpServlet- Throws:
ServletException
-
doGet
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException - Overrides:
doGetin classHttpServlet- Throws:
ServletExceptionIOException
-
