1 / 12

Understanding JavaServer Pages

Understanding JavaServer Pages. 鄧姚文 joseph.deng@gmail.com. Outline. What is a JSP page? Hello User Servlet or JSP JSP architecture models. 什麼是 JSP?. A JSP page is a web page that contains Java code along with the HTML tags.

laban
Download Presentation

Understanding JavaServer Pages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Understanding JavaServer Pages 鄧姚文 joseph.deng@gmail.com

  2. Outline What is a JSP page? Hello User Servlet or JSP JSP architecture models

  3. 什麼是 JSP? • A JSP page is a web page that contains Java code along with the HTML tags. • When accessed by a client, the Java code within the page is executed on the server side, producing textual data. • This data, which is surrounded by HTML tags, is sent as a normal HTML page to the client. • The client has no knowledge of the Java code. • The code is replaced by the HTML generated by the Java code before the page is sent to the client.

  4. Server-side includes Embedding programming languages within HTML A dynamic web page consists of markup language code as well as programming language code Instead of serving the page as is to the clients, a server processes the programming language code, replaces the code with the data generated by the code, and then sends the page to the client

  5. Hello User • 寫一個 JSP 網頁,向使用者問好 • 使用 Tomcat • 使用 Eclipse • HTML + servlet • HTML + JSP

  6. Servlet OR JSP? • 當程式邏輯多過畫面時,用 servlet • 資料庫 • 數學計算 • 授權檢查 • 當畫面設計多過程式邏輯時,用 JSP

  7. JSP Architecture Models The Model 1 architecture The Model 2 architecture The difference between the two lies in the way they handle the requests

  8. The Model 1 architecture

  9. The Model 1 architecture the target of every request is a JSP page there is no central component that controls the workflow of the application suitable for simple applications embedding business logic using big chunks of Java code into the JSP page does not promote reusability of application components

  10. The Model 2 architecture

  11. The Model 2 architecture follows the Model-View-Controller (MVC) design pattern the targets of all the requests are servlets that act as the controller for the application the JSP pages form the view of the application separation of responsibilities: ease of maintenance

  12. SUMMARY In this chapter, we learned about the basics of JavaServer Pages technology and serverside includes briefly compared JSP pages to servlets and discussed when it is appropriate to use one or the other discussed the two JSP architectural models and how they differ in their request-handling process

More Related