1 / 25

CSE446 Software Quality Management

CSE446 Software Quality Management. Orhan Ba şar Evren. Spring 2014. Yazılım ve Uyguluma Geliştirme Yöneticisi. Today’s Overview. Quick Review of HTTP and Servlets JSP and JSTL JSP Overview Code Samples JSP Lifecycle Common JSTL Tags JSF – (Part 1) JSF Overview JSF Components

wilton
Download Presentation

CSE446 Software Quality Management

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. CSE446 Software Quality Management Orhan Başar Evren Spring 2014 Yazılım ve Uyguluma Geliştirme Yöneticisi

  2. Today’s Overview • Quick Review of HTTP and Servlets • JSP and JSTL • JSP Overview • Code Samples • JSP Lifecycle • Common JSTL Tags • JSF – (Part 1) • JSF Overview • JSF Components • JSF Lifecycle CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  3. JSPJava Server Pages CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  4. JSP – Java Server Pages • JSP is a technology for developing dynamic and static web pages. • <% Java Code %> in HTML page • High level abstraction of Java Servlets • A servlet for each JSP at runtime CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  5. JSP – Sample Code <html> <body> <h1> Hello <% java.util.Date date = new java.util.Date(); out.print("from JSP"); %> </h1> Current date is : <%= date %> </body> </html> CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  6. JSP – Java Server Pages CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  7. JSP – Auto generated Servlet Code out.write("<html>\n"); out.write(" <body>\n"); out.write(" <h1>\n"); out.write(" Hello \n"); java.util.Datedate = new java.util.Date(); out.print("from JSP"); out.write(" </h1>\n"); out.write(" </br>\n"); out.write(" Current date is : "); out.print( date ); out.write("\n"); out.write(" </body>\n"); out.write("</html>\n"); CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  8. JSTL – JSP Standard Tag Library • Java ServerPages Standard Tag Library • Extends the JSP Specification for adding tab library for common tags : • Data access • Data Process • Logical conditions and loops • Internationalization • Many other <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  9. JSTL – JSP Standard Tag Library • Some Core Tags : • <c:set></c:set> • <c:if> </c:if> • <c:forEach> </c:forEach> • <c:catch></c:catch> • <c:import></c:import> • Usage Examples: • <c:setvar="foo" scope="session" value="..."/> • <c:if test="${!empty param.Add}"> …. </c:if> CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  10. JSTL – JSP Standard Tag Library • Some InternationalizationTags : • <fmt:formatNumber/> • <fmt:formatDate/> • <fmt:setLocale/> • <fmt:message> • </fmt:message> • Usage Examples: • <fmt:message key=“username_label"/> • <fmt:formatNumber value="${book.price}" type="currency"/> • <fmt:formatDate value="${now}" type="date“/> CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  11. JSTL – JSP Standard Tag Library • Some SQL Tags : • <sql:setDataSource/> • <sql:query/> • <sql:transaction/> • <sql:update> • Usage Examples: • <sql:setDataSourcedataSource="jdbc/BookDB" /> • <sql:queryvar="books" > select * from books</sql:query> CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  12. JSTL – JSP Standard Tag Library • Some Functions : • <fn:length/> • <fn:toUpperCase/> • <fn:substring/> • <fn:replace/> • Usage Examples: • <c:if test="${fn:length(param.username) > 0}" > … • <c:setvar=“str2" value="${fn:substring(str1, 5, 15)}" /> CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  13. JSP – Custom Tags public class HelloTag extends SimpleTagSupport{ public void doTag() throws JspException, IOException { JspWriterout = getJspContext().getOut(); out.println("Hello Custom Tag!"); } } • Define TDL file (XML defination file not listed here) • Usage Examples: • <%@ taglib prefix="ex" uri="WEB-INF/custom.tld"%> • <ex:Hello> </ex:Hello> CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  14. JSP - deprecated ? JSP is considered "deprecated" as of the Java Enterprise Edition and replaced by JSF. However, it is still commonly used: • Default view technology of Spring MVC • Google cloud App Engine: JSP interface support • Possible to combine with JSF • Many other applications exists Because it is supported with all Java Web Servers, while JSF is supported by Java EE compliant web servers. CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  15. JSFJava Server Faces CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  16. JSF - Java Server Faces • Server side user interface component framework • JSF is specification for a web application development framework • MVC based pattern : Better separation of behavior and presentation • Built-in component model • Facelets: reusable and extendable CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  17. JSF - Java Server Faces CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  18. JSF - Java Server Faces CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  19. JSF - Java Server Faces • API Specification: JSF 2.2 (contains standard components) • Major Implementations: • Oracle Mojarra • Apache MyFaces • Major Componenet Libraries: • RichFaces, PrimeFaces, ICEFaces, etc. CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  20. JSF - Java Server Faces • Primefaces’ component examples CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  21. JSF - Life Cycle • Handling incoming requests • Decoding parameters • Modifying and saving state • Rendering web pages to the browser JSF framework manages lifecycle phases automatically, however it also allows to monitor and manage phases manually CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  22. JSF - Life Cycle CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  23. JSF - Life Cycle • Restore View Phase :builds the view of the page, wires events and components and saves the view in FacesContext • Apply Request Values Phase:new (local) values of the components are set by request parameters • Process Validations Phase: values of the components are validated by rules • Update Model Values Phase:Sets local values of the components to server-side object • Invoke Application Phase:handling application level events like form submitting, linking, redirecting etc. • Render Response Phase:building the view and rendering the page CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  24. JSF - Life Cycle - Monitor public class LifeCycleListener implements PhaseListener{ public PhaseIdgetPhaseId() { return PhaseId.ANY_PHASE; } public void beforePhase(PhaseEvent event) { System.out.println(“BEFORE " + event.getPhaseId()); } public void afterPhase(PhaseEvent event) { System.out.println(“AFTER " + event.getPhaseId()); } } faces-config file: <lifecycle> <phase-listener>package.LifeCycleListener</phase-listener> </lifecycle> CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

  25. Images are referenced from http://docs.oracle.com/javaee/7/tutorial/doc/home.htm CSE446 Software Quality Management Spring 2014 – Orhan Başar Evren - Netaş

More Related