Package org.jumpmind.symmetric.web
Class ServletUtils
java.lang.Object
org.jumpmind.symmetric.web.ServletUtils
Utility methods for working with
Servlet
s-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ServerSymmetricEngine
findEngine
(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.ServletContext ctx) static String
getEndpointNameFromUrl
(jakarta.servlet.http.HttpServletRequest request) static String
getEngineNameFromUrl
(jakarta.servlet.http.HttpServletRequest req) static String
getParameter
(jakarta.servlet.http.HttpServletRequest request, String name) Returns the parameter with that name, trimmed to nullstatic String
getParameter
(jakarta.servlet.http.HttpServletRequest request, String name, String defaultValue) Returns the parameter with that name, trimmed to null.static long
getParameterAsNumber
(jakarta.servlet.http.HttpServletRequest request, String name) static SymmetricEngineHolder
getSymmetricEngineHolder
(jakarta.servlet.ServletContext ctx) static String
normalizeRequestUri
(jakarta.servlet.http.HttpServletRequest httpRequest) Returns the part of the path we are interested in when doing pattern matching.static boolean
sendError
(jakarta.servlet.http.HttpServletResponse resp, int statusCode) Because you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.static boolean
Because you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.static boolean
sendError
(jakarta.servlet.ServletResponse resp, int statusCode) Because you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.static boolean
Because you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.static String
whereAreYou
(jakarta.servlet.http.HttpServletRequest request)
-
Constructor Details
-
ServletUtils
public ServletUtils()
-
-
Method Details
-
sendError
public static boolean sendError(jakarta.servlet.http.HttpServletResponse resp, int statusCode) throws IOException Because you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.- Parameters:
resp
-statusCode
-- Returns:
- true if the error could be sent to the response
- Throws:
IOException
-
whereAreYou
-
sendError
public static boolean sendError(jakarta.servlet.http.HttpServletResponse resp, int statusCode, String message) throws IOException Because you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.- Parameters:
resp
-statusCode
-message
- a message to put in the body of the response- Returns:
- true if the error could be sent to the response
- Throws:
IOException
-
sendError
public static boolean sendError(jakarta.servlet.ServletResponse resp, int statusCode) throws IOException Because you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.- Parameters:
resp
-statusCode
-- Returns:
- true if the error could be sent to the response
- Throws:
IOException
-
sendError
public static boolean sendError(jakarta.servlet.ServletResponse resp, int statusCode, String message) throws IOException Because you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.- Parameters:
resp
-statusCode
-message
- a message to put in the body of the response- Returns:
- true if the error could be sent to the response
- Throws:
IOException
-
normalizeRequestUri
Returns the part of the path we are interested in when doing pattern matching. This should work whether or not the servlet or filter is explicitly mapped inside of the web.xml since it always strips off the contextPath.- Parameters:
httpRequest
-- Returns:
-
findEngine
public static ServerSymmetricEngine findEngine(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.ServletContext ctx) -
getEngineNameFromUrl
-
getParameter
Returns the parameter with that name, trimmed to null- Parameters:
request
-name
-- Returns:
-
getParameter
public static String getParameter(jakarta.servlet.http.HttpServletRequest request, String name, String defaultValue) Returns the parameter with that name, trimmed to null. If the trimmed string is null, defaults to the defaultValue.- Parameters:
request
-name
-- Returns:
-
getParameterAsNumber
public static long getParameterAsNumber(jakarta.servlet.http.HttpServletRequest request, String name) -
getSymmetricEngineHolder
-
getEndpointNameFromUrl
-