標籤:patch today ssi ext 繼承 相對 建立 路徑 理論
1.servlet理論上可以處理多種形式的請求響應形式 ,http只是其中之一 ,所以HttpServletRequest、 HttpServletResponse分別是ServletRequest和ServletResponse的子類 ,HttpServletRequest和ServletRequest都是介面 ,HttpServletRequest繼承自ServletRequest ,HttpServletRequest比ServletRequest多了一些針對於Http協議的方法。 如 getHeader(String name), getMethod() , getSession() 等
2.HttpServletRequest 的實現是根據不同伺服器的,tomcat有tomcat的實現,webLogic有webLogic的實現
3.產生唯一檔案名:UUID.randomUUID();
4.WEB容器在啟動時,它會為每個WEB應用程式都建立一個對應的ServletContext對象,它代表當前web應用。由於一個WEB應用中的所有Servlet共用同一個ServletContext對象,因此Servlet對象之間可以通過ServletContext對象來實現通訊。多個Servlet通過ServletContext對象實現資料共用。
如實現Servlet的轉寄。
RequestDispatcher rd = getServletContext().getRequestDispatcher(“/1.jsp”); //相對當前內容相關的根目錄,而不是檔案在物理伺服器上的根路徑
rd.forward(request,response);
實現資料的互動
this.getServletContext().setAttribute("today","Yestoday");
Java Web學習筆記-1