# 网络上下文对象

在网络环境下，如下对象可以直接访问（注意：它们是对象，不是映射或者命名空间）：

* **#request** ：直接访问与当前请求相关联的`javax.servlet.http.HttpServletRequest`对象。

  ```java
  ${#request.getAttribute('foo')}
  ${#request.getParameter('foo')}
  ${#request.getContextPath()}
  ${#request.getRequestName()}
  ...
  ```
* **#session** ：直接访问与当前请求相关联的`javax.servlet.http.HttpSession`对象。

  ```java
  ${#session.getAttribute('foo')}
  ${#session.id}
  ${#session.lastAccessedTime}
  ...
  ```
* **#servletContext**：直接访问与当前请求相关联的`javax.servlet.ServletContext`对象。

  ```java
  ${#servletContext.getAttribute('foo')}
  ${#servletContext.contextPath}
  ...
  ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jack80342.gitbook.io/thymeleaf/i.-using-thymeleaf/18-appendix-a-expression-basic-objects/web-context-objects.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
