在 java 网络应用程序中找不到对象实例化(响应、请求、应用程序)

Can't find Instantiation of objects (response, request, application) in java web app

我必须开发别人开发的 java 网络应用程序。由于我是 java 网络开发的新手,我扫描了一些代码并偶然发现了一些实例化对象,在这些实例化对象中我找不到对其实例化位置的引用,即在 .jsp 页面

    ...some includes
    UserFactory uf=null;

    if (application.getAttribute("userFactory") == null){
    ...
    strUser=request.getParameter("user");
    pw=request.getParameter("pw");
    ...

(通知application, request, response)

现在我意识到它可能已经在某些包含中声明了,我确实检查了所有这些但找不到声明(尽管我确实监督了它)。 现在的问题是: 这些对象是否以某种方式由 tomcat 全局实例化(如果是这样,我在哪里可以找到它),如果不是这种情况,人们将如何在一个相当大的项目中找到它们(顺便说一句,我正在使用 Eclipse JUNO) (即像 eclipse 的一个功能来查找实例化),最好不要手动查看每个包含。

它们是 servlet 引擎为所有 JSP 页面提供的变量。使用 servlet,您将获得 HttpServletRequestHttpServletResponse 传递给 doXXX 方法,它们在 JSP 处理期间也可用。

在 JSP 中,这些变量称为 "implicit objects"。在此处查找 JSP 中可用的所有隐式对象:http://docs.oracle.com/javaee/5/tutorial/doc/bnahq.html#bnaij:

Implicit Objects

The JSP expression language defines a set of implicit objects:

  • pageContext: The context for the JSP page. Provides access to various objects including:
    • servletContext: The context for the JSP page’s servlet and any web components contained in the same application. See Accessing the Web Context.
    • session: The session object for the client. See Maintaining Client State.
    • request: The request triggering the execution of the JSP page. See Getting Information from Requests.
    • response: The response returned by the JSP page. See Constructing Responses.

In addition, several implicit objects are available that allow easy access to the following objects:

  • param: Maps a request parameter name to a single value
  • paramValues: Maps a request parameter name to an array of values
  • header: Maps a request header name to a single value
  • headerValues: Maps a request header name to an array of values
  • cookie: Maps a cookie name to a single cookie
  • initParam: Maps a context initialization parameter name to a single value

Finally, there are objects that allow access to the various scoped variables described in Using Scope Objects.

  • pageScope: Maps page-scoped variable names to their values
  • requestScope: Maps request-scoped variable names to their values
  • sessionScope: Maps session-scoped variable names to their values
  • applicationScope: Maps application-scoped variable names to their values