Package org.jumpmind.symmetric.web
Class ServletUtils
java.lang.Object
org.jumpmind.symmetric.web.ServletUtils
Utility methods for working with
Servlets-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ServerSymmetricEnginefindEngine(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.ServletContext ctx) static StringgetEngineNameFromUrl(jakarta.servlet.http.HttpServletRequest req) static StringgetParameter(jakarta.servlet.http.HttpServletRequest request, String name) Returns the parameter with that name, trimmed to nullstatic StringgetParameter(jakarta.servlet.http.HttpServletRequest request, String name, String defaultValue) Returns the parameter with that name, trimmed to null.static longgetParameterAsNumber(jakarta.servlet.http.HttpServletRequest request, String name) static SymmetricEngineHoldergetSymmetricEngineHolder(jakarta.servlet.ServletContext ctx) static StringnormalizeRequestUri(jakarta.servlet.http.HttpServletRequest httpRequest) Returns the part of the path we are interested in when doing pattern matching.static booleansendError(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 booleanBecause you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.static booleansendError(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 booleanBecause you can't send an error when the response is already committed, this helps to avoid unnecessary errors in the logs.static StringwhereAreYou(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
-