What Is Servlet?
Servlet包含HTTP request與HTTP response
執行專案Maven Builder Goal:tomcat7:run
進到http://localhost:8090/
按下F12再按NetWork並F5重整可見到
HTTP response內容如下:
整體運行方式:
Browser sends Http Request to Web Server
Code in Web Server =>Input:HttpRequest ,Output:HttpResponse
Web Server response with Http Response
而LoginServlet.java內定義的@WebServlet來自javaEE6的套件
指定了以下網址的request與response行為
跟web.xml轉向是一樣的(根據web.xml定義localhost:8090會導到/login.do這個Servlet內)
而瀏覽器發動的是Get Method,所以對應的LoginServlet.java內要定義
doGet這個方法