CS520 Web Programming Bits and Pieces of Web Programming (I) Chengyu Sun California State University, Los Angeles.

Slides:



Advertisements
Similar presentations
Developing in CAS. Why? As distributed you edit CAS 3 with Eclipse and build with Maven 2 – Best Practice for Release Engineering – Difficult edit-debug.
Advertisements

WEB1P servintro1 Introduction to servlets and JSP Dr Jim Briggs.
DT211/3 Internet Application Development
DT228/3 Web Development JSP: Directives and Scripting elements.
JSP Architecture  JSP is a simple text file consisting of HTML or XML content along with JSP elements  JSP packages define the interface for the compiled.
Slide 1 of 9 Presenting 24x7 Scheduler The art of computer automation Press PageDown key or click to advance.
© 2006 by IBM 1 How to use Eclipse to Build Rich Internet Applications With PHP and AJAX Phil Berkland IBM Software Group Emerging.
Struts 2.0 an Overview ( )
UNIT-V The MVC architecture and Struts Framework.
Spring Roo CS476 Aleksey Bukin Peter Lew. What is Roo? Productivity tool Allows for easy creation of Enterprise Java applications Runs alongside existing.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 9 JavaServer Pages (JSP) (Based on Møller.
TestNG … and improving use of JUnit Dec 11, 2008 C. Gordon Huffman.
WaveMaker Visual AJAX Studio 4.0 Training Troubleshooting.
Logging with Log4j. Introduction Logging - chronological and systematic record of data processing events in a program. Possible goals: Create an audit.
BEST PRACTICES - Java By Configuration Use global-forwards/results Helps to avoid duplicate jsp files and redundancy forward mapping.
© 2012 LogiGear Corporation. All Rights Reserved Robot framework.
Designing For Testability. Incorporate design features that facilitate testing Include features to: –Support test automation at all levels (unit, integration,
JSP Most of the web developers deploying web applications using servlets mixes the presentation logic and business logic. Separation of business logic.
LogBox Enterprise Logging Brad Wood
Running Kuali: A Technical Perspective Ailish Byrne - Indiana University Jay Sissom - Indiana University Foundation.
Fall 2007cs4201 Advanced Java Programming Umar Kalim Dept. of Communication Systems Engineering
Chapter 7 Using Custom Tag Libraries and the JSP Standard Tag Library.
Unit Testing with JUnit and Clover Based on material from: Daniel Amyot JUnit Web site.
FT228/3 Web Development Error processing. Introduction READ Chapter 9 of Java Server Pages from O’reilly 2 nd Edition Need to be able to 1) Diagnose and.
Running Kuali: A Technical Perspective Ailish Byrne (Indiana University) Jonathan Keller (University of California, Davis)
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
The Log4E logging plug-in David Gallardo. What is logging good for? Tracing program execution during development Debugging Providing an audit trail for.
Enterprise Java v090125Dev Env Overview1 Enterprise Java ( ) Development Environment Overview.
Page 1 – Autumn 2009Steffen Vissing Andersen SDJ I1, Autumn 2009 Agenda: Java API Documentation Code Documenting (in javadoc format) Debugging.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Modern Programming Language. Web Container & Web Applications Web applications are server side applications The most essential requirement.
® IBM Software Group © 2006 IBM Corporation How to utilize logging in EGL This Learning Module shows how to utilize the open source log4j project from.
DT228/3 Web Development JSP: Actions elements and JSTL.
Google Code Libraries Dima Ionut Daniel. Contents What is Google Code? LDAPBeans Object-ldap-mapping Ldap-ODM Bug4j jOOR Rapa jongo Conclusion Bibliography.
CS520 Web Programming Bits and Pieces of Web Programming (II) Chengyu Sun California State University, Los Angeles.
© 2001 By Default! A Free sample background from Slide 1 Motivation CMW logging Real-Time Task CMW Server Logging thread.
CS320 Web and Internet Programming Web Application and MVC Chengyu Sun California State University, Los Angeles.
Milan Vukoje State of the art logging October 23 rd 2013.
CS520 Web Programming Introduction to Maven Chengyu Sun California State University, Los Angeles.
Preface IIntroduction Course Objectives I-2 Course Content I-3 1Introduction to Oracle Reports Developer Objectives 1-2 Business Intelligence 1-3 Enterprise.
Copyright © 2010 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are trademarks of Accenture. ODS Tools – Fannie Mae.
CS320 Web and Internet Programming Introduction to Java Servlets Chengyu Sun California State University, Los Angeles.
CS520 Web Programming Spring – Web MVC Chengyu Sun California State University, Los Angeles.
CS520 Web Programming Spring – Web MVC Chengyu Sun California State University, Los Angeles.
CS520 Web Programming Bits and Pieces of Web Programming (I) Chengyu Sun California State University, Los Angeles.
Chengyu Sun California State University, Los Angeles
CS3220 Web and Internet Programming Introduction to Java Servlets
CS3220 Web and Internet Programming RESTful Web Service
CS5220 Advanced Topics in Web Programming Version Control with Git
CS520 Web Programming Introduction to Maven
Chengyu Sun California State University, Los Angeles
Designing For Testability
Testing and Debugging.
Introduction to JSP Liu Haibin 12/09/2018.
Knowledge Byte In this section, you will learn about:
Chengyu Sun California State University, Los Angeles
CS5220 Advanced Topics in Web Programming Course Overview
Monitoring Java Applications with JAMon
Web Development in Microsoft Visual Studio 2013
Introduction to Struts
JSP Directives 1-Jan-19.
Fall 2018 CISC124 2/1/2019 CISC124 Note that the next assignment, on encapsulation, is due next Wednesday at 7pm – not Friday. The next Quiz is not until.
CS3220 Web and Internet Programming Introduction to Java Servlets
CS 240 – Advanced Programming Concepts
Chengyu Sun California State University, Los Angeles
CS4961 Software Design Laboratory Understand Aquila Backend
Chengyu Sun California State University, Los Angeles
CS5220 Advanced Topics in Web Programming Course Overview
Plug-In Architecture Pattern
Presentation transcript:

CS520 Web Programming Bits and Pieces of Web Programming (I) Chengyu Sun California State University, Los Angeles

Roadmap Logging Testing View Template Framework Exception Handling

Logging Use print statements to assist debugging Why do we want to do that when we have GUI debugger?? public void foo() { System.out.println( “loop started” ); // some code that might get into infinite loop … System.out.println( “loop finished” ); }

Requirements of Good Logging Tools Minimize performance penalty Support different log output Console, file, database, … Support different message levels Fatal, error, warn, info, debug, trace Easy configuration

Java Logging Libraries Logging implementations Log4j - java.util.logging in JDK Logging API Apache Commons Logging (JCL) Simple Logging Façade for Java (SLF4J) -

Choose Your Logging Libraries Log4j Widely used Good performance Easy configuration java.util.logging Part of JDK, i.e. no extra library dependency Commons Logging Determines logging implementation at runtime SLF4j Statically linked to a logging implementation  Cleaner design  Better performance  Less problem

Using Log4j and SLF4j Library dependencies Coding Creating a Logger Logging statements Configuration Output format

Log4j Configuration File log4j.xml or log4j.properties Appender Output type Output format Logger Package or class selection Message level

Log4j PatternLayout docs/org/apache/log4j/PatternLayout.ht ml

Logging in CSNS2 src/main/resources/log4j.xml build.properties app.log.dir app.log.level Use of Log Viewer plugin in Eclipse

Java Testing Frameworks JUnit Widely used and supported TestNG Technically superior to JUnit (for a while) but not as widely used or supported

What We Want From a Testing Framework Automation Including setup and tear-down Grouping and selection Test Dependency Skip tests that depend on tests that already failed Run independent test in parallel Report Other, e.g. tool support, API, dependency injection, and so on

Maven Support for JUnit/TestNG Library dependency Directory structure src/test/java src/test/resources The surefire plugin

Basic TestNG Method Class Annotations for various before/after methods

Group and groups dependsOnMethods dependsOnGroups

Test Suite A test suite is represented by an XML file and contains one or more tests. Select tests by method, class, package, and group Include and exclude

Test Suite Example testng.xml

TestNG in CSNS2 Configuration Test classes inherit from Spring TestNG support BeforeSuite and AfterSuite methods

More About TestNG TestNG Documenation – main.html main.html Next Generation Java Testing by Cédric Beust and Hani Suleiman

Apache Tiles A template framework for JSP Similar to Master Page and Razor in ASP.NET

The Need for View Templates Header Footer Content 1 Header Footer Content N page1.jsppageN.jsp

Why JSP Is Not Enough It breaks HTML syntax, e.g. in header.jsp and in footer.jsp. It’s difficult to create and manage multiple complex templates.

Basic Tiles Usage Template page = JSP + placeholders (i.e. attributes), Content: JSP, string, other tiles Definition: combine template and content Tiles Tag Library

A Tiles Example Header Footer Content 1 Header Footer Content 2 page1.jsppage2.jsp

Tiles – Template Page Header Footer template.jsp

Tiles – Content Pages Content 1Content 2 page1.jsppage2.jsp

Tiles – Definitions

Resolve Tiles Views in Spring /WEB-INF/tiles.xml

Tiles Usage in CSNS2 WEB-INF/layout for template and header/footer pages WEB-INF/content for content pages WEB-INF/tiles.xml for definitions

Problem with Java Exceptions Too many checked exceptions Checked vs. Runtime exceptions Require lots of boilerplate exception handling code

Spring’s Solution to the Exception Problem Use primarily runtime exceptions Separate exception handling code into exception handlers

Controller Exception Handing in Spring An Exception Resolver handles all runtime exceptions thrown by controllers SimpleMappingExceptionResolverSimpleMappingExceptionResolver maps different exceptions to different views

ExceptionResolver in CSNS2 <bean id="exceptionResolver“ class="csns.web.resolver.ExceptionResolver"> exception/access exception/mail A SimpleMappingExceptionResolver with additional loggin.