160 likes | 310 Views
Chapter 3. JSP Overview. The Problem with Servlets. processing the request and generating the response are both handled by a single servlet class Java programming knowledge is needed to develop and maintain all aspects of the application
E N D
Chapter 3 JSP Overview
The Problem with Servlets • processing the request and generating the response are both handled by a single servlet class • Java programming knowledge is needed to develop and maintain all aspects of the application • Changing the look and feel of the application, or adding support for a new type of client requires the servlet code to be updated and recompiled • It's hard to take advantage of web page development tools when designing the application interface
The Advantage of JSP • separating the request processing and business logic from presentation makes it possible to divide the development tasks among people with different skills
JSP Processing • When a JSP page request is processed, the template text and dynamic content generated by the JSP elements are merged, and the result is sent as the response to the browser
JSP Processing • the server needs a JSP container to process JSP pages • The JSP container initiates the translation phase for a page automatically when it receives the first request for the page • turns the JSP page into a servlet • compiles the servlet class • precompilation of a JSP page • request processing phase: invoking the JSP page implementation class • As long as the JSP page remains unchanged, any subsequent request goes straight to the request processing phase • When the JSP page is modified, it goes through the translation phase again • it's loaded once and called repeatedly, until the server is shut down
JSP Elements • Directive • Action • scripting • Expression Language (EL) expression • JavaBeans components
JSP Elements • Directive elements
JSP Elements • Standard action elements
JSP Elements • Custom action elements • The JSP Standard Tag Library (JSTL)
JSP Elements • Scripting elements • allow you to add small pieces of code (typically Java code) in a JSP page
JSP Elements • Expression Language expressions • JavaBeans components • a JavaBeans component is a Java class that complies with certain coding conventions • components are typically used as containers for information that describes application entities, such as a customer or an order
JSP Application Design with MVC • MVC roles in a pure JSP scenario