Forward Servlet B Request A forward B HTTP
Forward Servlet B Request A forward B HTTP Response B Servlet. A HTTP Request A Browser HTTP Request A HTTP Response B HTTP Server HTTP Request A Servlet Container HTTP Response B Static Content 2
Servlet. A Redirect HTTPResponse A send. Redirect B HTTP Request A Browser HTTP Request A send. Redirect B HTTP Server HTTP Request A Servlet Container send. Redirect B Static Content Servlet. B HTTP Request B Browser HTTP Request B HTTP Response B HTTP Server HTTP Request B HTTP Response B Servlet Container HTTP Response B Static Content 3
Forward vs Redirect interface Request. Dispatcher # forward(Servlet. Request request, Servlet. Response response) Forwards a request from a servlet to another resource (servlet, JSP file, or HTML file) on the server interface Http. Servlet. Response # send. Redirect(java. lang. String location) Sends a temporary redirect response to the client using the specified redirect location URL and clears the buffer. Java for the Web with Servlets, JSP, and EJB: A Developer's Guide to J 2 EE Solutions By Budi Kurniawan Part I, Chapter 3, Request Dispatching 4
Request. Dispatcher Interface Servlet. Context # get. Request. Dispatcher(java. lang. String path) Returns a Request. Dispatcher object that acts as a wrapper for the resource located at the given path. Interface Servlet. Request # get. Request. Dispatcher(java. lang. String path) Returns a Request. Dispatcher object that acts as a wrapper for the resource located at the given path. 5
Основные интерфейсы l l l javax. servlet. Filter. Chain javax. servlet. Filter. Config 18
javax. servlet. Filter. Config l l public String get. Filter. Name() public String get. Init. Parameter(String parameter. Name) public java. util. Enumeration get. Init. Parameter. Names() public Servlet. Context get. Servlet. Context() обращение к атрибуту : demofilter. jsp ex 05: простая фильтрация значения атрибута : My. Filter. java 21
http: //docs. oracle. com/cd/B 15904_01/web. 1012/b 14017/filters. htm#i 1000654 Oracle® Application Server Containers for J 2 EE Servlet Developer's Guide 22
- Slides: 22