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

标签 java eclipse web tomcat7

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

    ...some includes
    UserFactory uf=null;

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

(通知应用程序、请求、响应)

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

最佳答案

在 JSP 中,这些变量称为“隐式对象”。在此处查找 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

关于java - 在java web应用程序中找不到对象的实例化(响应、请求、应用程序),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32047452/

相关文章:

javascript - 第一个函数调用 html 按钮 onclick,但不调用任何其他函数

web - Go Web 应用程序的根是如何解析的?

eclipse - 无法使用 Eclipse Egit 提交文件

java - 如何在 Eclipse 中捕获控制台输出

java - 需要解释搜索最小大和的算法

java - 如何从 java 重新启动我的 tp-link 路由器

java - 完全不知道为什么 eclipse 会给出这个错误

javascript - jquery addclass 显示图片查询

java - ExecutorService 和 AtomicInteger : RejectedExecutionException

java - HashMap 和 int 作为键