ServletContext.getRequestDispatcher() vs ServletRequest.getRequestDispatcher()

后端 未结 6 1902
别跟我提以往
别跟我提以往 2020-12-02 15:58

why

getRequestDispatcher(String path) of the ServletRequest interface cannot extend outside the current servlet context

<
6条回答
  •  -上瘾入骨i
    2020-12-02 16:43

    Context is stored at the application level scope where as request is stored at page level i.e to say

    Web Container brings up the applications one by one and run them inside its JVM. It stores a singleton object in its jvm where it registers anyobject that is put inside it.This singleton is shared across all applications running inside it as it is stored inside the JVM of the container itself.

    However for requests, the container creates a request object that is filled with data from request and is passed along from one thread to the other (each thread is a new request that is coming to the server), also request is passed to the threads of same application.

提交回复
热议问题