Package org.kohsuke.stapler
Class Stapler
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.kohsuke.stapler.Stapler
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable
public class Stapler
extends jakarta.servlet.http.HttpServlet
Maps an HTTP request to a method call / JSP invocation against a model object
by evaluating the request URL in a EL-ish way.
This servlet should be used as the default servlet.
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.apache.commons.beanutils.ConvertUtilsBeanThis is theConverterregistry that Stapler uses, primarily for form-to-JSON binding inStaplerRequest2.bindJSON(Class, JSONObject)and its family of methods. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidRebuild the internal cache for static resources.static StringEscapes HTML/XML unsafe characters for the PCDATA section.voidforward(jakarta.servlet.RequestDispatcher dispatcher, StaplerRequest2 req, jakarta.servlet.http.HttpServletResponse rsp) Deprecated.static ClassLoadergetClassLoader(jakarta.servlet.ServletContext context) Deprecated.static StaplerGets the currentStaplerthat the calling thread is associated with.static StaplerRequestDeprecated.static StaplerRequest2Gets the currentStaplerRequest2that the calling thread is associated with.static StaplerResponseDeprecated.static StaplerResponse2Gets the currentStaplerResponse2that the calling thread is associated with.static StringgetViewURL(Class clazz, String jspName) Gets the URL (e.g., "/WEB-INF/side-files/fully/qualified/class/name/jspName") from a class and the JSP name.static ObjectFor XSS prevention, escape unsafe characters in String by default, unless it's specifically wrapped inRawHtmlArgument.static Object[]htmlSafeArguments(Object[] args) voidinit(jakarta.servlet.ServletConfig servletConfig) voidinvoke(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse rsp, Object root, String url) Performs stapler processing on the given root object and request URL.static booleanUsed to detect exceptions thrown when writing content that seem to be due merely to a closed socket.static org.apache.commons.beanutils.ConverterlookupConverter(Class type) protected voidservice(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse rsp) static voidsetClassLoader(jakarta.servlet.ServletContext context, ClassLoader classLoader) Deprecated.static voidSets the specified object as the root of the web application.Methods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, serviceMethods inherited from class jakarta.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Field Details
-
CONVERT_UTILS
public static final org.apache.commons.beanutils.ConvertUtilsBean CONVERT_UTILSThis is theConverterregistry that Stapler uses, primarily for form-to-JSON binding inStaplerRequest2.bindJSON(Class, JSONObject)and its family of methods.
-
-
Constructor Details
-
Stapler
public Stapler()
-
-
Method Details
-
init
public void init(jakarta.servlet.ServletConfig servletConfig) throws jakarta.servlet.ServletException - Specified by:
initin interfacejakarta.servlet.Servlet- Overrides:
initin classjakarta.servlet.GenericServlet- Throws:
jakarta.servlet.ServletException
-
buildResourcePaths
public void buildResourcePaths()Rebuild the internal cache for static resources. -
getWebApp
-
service
protected void service(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse rsp) throws jakarta.servlet.ServletException, IOException - Overrides:
servicein classjakarta.servlet.http.HttpServlet- Throws:
jakarta.servlet.ServletExceptionIOException
-
invoke
public void invoke(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse rsp, Object root, String url) throws IOException, jakarta.servlet.ServletException Performs stapler processing on the given root object and request URL.- Throws:
IOExceptionjakarta.servlet.ServletException
-
isSocketException
Used to detect exceptions thrown when writing content that seem to be due merely to a closed socket.- Parameters:
x- an exception that got caught- Returns:
- true if this looks like a closed stream, false for some real problem
- Since:
- 1.222
-
forward
public void forward(jakarta.servlet.RequestDispatcher dispatcher, StaplerRequest2 req, jakarta.servlet.http.HttpServletResponse rsp) throws jakarta.servlet.ServletException, IOException - Throws:
jakarta.servlet.ServletExceptionIOException
-
getViewURL
Gets the URL (e.g., "/WEB-INF/side-files/fully/qualified/class/name/jspName") from a class and the JSP name. -
setRoot
Sets the specified object as the root of the web application.This method should be invoked from your implementation of
ServletContextListener.contextInitialized(ServletContextEvent).This is just a convenience method to invoke
servletContext.setAttribute("app",rootApp).The root object is bound to the URL '/' and used to resolve all the requests to this web application.
-
setClassLoader
@Deprecated public static void setClassLoader(jakarta.servlet.ServletContext context, ClassLoader classLoader) Deprecated.Sets the classloader used byStaplerRequest2.bindJSON(Class, JSONObject)and its sibling methods. -
getClassLoader
Deprecated. -
getClassLoader
Deprecated. -
getCurrentRequest2
Gets the currentStaplerRequest2that the calling thread is associated with.- Returns:
- null, if called from outside an HTTP handling thread
-
getCurrentRequest
Deprecated. -
getCurrentResponse2
Gets the currentStaplerResponse2that the calling thread is associated with.- Returns:
- null, if called from outside an HTTP handling thread
-
getCurrentResponse
Deprecated. -
getCurrent
Gets the currentStaplerthat the calling thread is associated with.- Returns:
- null, if called from outside an HTTP handling thread
-
lookupConverter
-
escape
Escapes HTML/XML unsafe characters for the PCDATA section. This method does not handle whitespace-preserving escape, nor attribute escapes. -
htmlSafeArguments
-
htmlSafeArgument
For XSS prevention, escape unsafe characters in String by default, unless it's specifically wrapped inRawHtmlArgument.
-
WebApp.getClassLoader()