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.

Slides:



Advertisements
Similar presentations
Topics Introduction Types of Errors Exceptions Exception Handling
Advertisements

Exceptions Chapter Throwing and Catching Exceptions When a program runs into a problem that it cannot handle, it throws an exception. Exceptions.
1 Week 11 l Basic Exception Handling »the mechanics of exceptions l Defining and Using Exceptions »some "simple" cases l Reality Check »guidelines for.
An Introduction to Java Programming and Object- Oriented Application Development Chapter 8 Exceptions and Assertions.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 15: Exception Handling.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 13 Exception Handling.
Chapter 16: Exception Handling C++ Programming: From Problem Analysis to Program Design, Fifth Edition.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 16: Exception Handling.
Slides prepared by Rose Williams, Binghamton University ICS201 Exception Handling University of Hail College of Computer Science and Engineering Department.
1 Lecture 11 Interfaces and Exception Handling from Chapters 9 and 10.
Chapter 51 Scripting With JSP Elements JavaServer Pages By Xue Bai.
Debugging Introduction to Computing Science and Programming I.
Working with ASP Pages. Slide 2 The Tag (1) Remember that most ASP.NET pages contain a single tag with the runat attribute set It’s possible to have multiple.
Web Development in Microsoft Visual Studio Slide 2 Lecture Overview Introduce Visual Studio 2013 Create a first ASP.NET application.
Nov 10, Fall 2006IAT 8001 Debugging. Nov 10, Fall 2006IAT 8002 How do I know my program is broken?  Compiler Errors –easy to fix!  Runtime Exceptions.
DT211/3 Internet Application Development JSP: Processing User input.
DT211/3 Internet Application Development
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Spring 2005 Chapter 8  Errors and Exceptions Throwable class.
DT228/3 Web Development JSP: Directives and Scripting elements.
JavaScript, Fourth Edition
12.1 Exceptions The limitations of traditional methods of exception handling Error conditions are a certainty in programming Programmers make.
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.
1 CIS336 Website design, implementation and management (also Semester 2 of CIS219, CIS221 and IT226) Lecture 9 JavaServer Pages (JSP) (Based on Møller.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
What is an exception? An exception is: – an event that interrupts the normal processing of the program. –an error condition that violates the semantic.
1 Chapter Eight Exception Handling. 2 Objectives Learn about exceptions and the Exception class How to purposely generate a SystemException Learn about.
ASP.NET Programming with C# and SQL Server First Edition Chapter 6 Debugging and Error Handling.
Object Oriented Programming
CIS 270—Application Development II Chapter 13—Exception Handling.
Chapter 12: Exception Handling
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
Slides Credit Umair Javed LUMS Web Application Development.
The Art of Debugging Shlomy Gantz 02/13/01MDCFUG.
CSCI 6962: Server-side Design and Programming Validation Tools in Java Server Faces.
Jun 16, 2014IAT 2651 Debugging. Dialectical Materialism  Dialectical materialism is a strand of Marxism, synthesizing Hegel's dialectics, which proposes.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
Dealing with Errors. Error Types Syntax Errors Runtime Errors Logical Errors.
Debugging in Java. Common Bugs Compilation or syntactical errors are the first that you will encounter and the easiest to debug They are usually the result.
JSP Exception Handling 20-Oct-15. JSP - E XCEPTION H ANDLING When you are writing JSP code, a programmer may leave a coding errors which can occur at.
Exception Handling in JAVA. Introduction Exception is an abnormal condition that arises when executing a program. In the languages that do not support.
Object Oriented Software Development 8. Exceptions, testing and debugging.
Introduction to Exception Handling and Defensive Programming.
Chapter 14: Exception Handling. Objectives In this chapter, you will: – Learn what an exception is – Learn how to handle exceptions within a program –
Exception Handling Unit-6. Introduction An exception is a problem that arises during the execution of a program. An exception can occur for many different.
Exceptions in Java. Exceptions An exception is an object describing an unusual or erroneous situation Exceptions are thrown by a program, and may be caught.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
BIO Java 1 Exception Handling Aborting program not always a good idea – can’t lose messages – E-commerce: must ensure correct handling of private.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
Sheet 3 HANDLING EXCEPTIONS Advanced Programming using Java By Nora Alaqeel.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Exceptions, handling exceptions & message boxes Year 11 Information Technology.
Exception Handling in Java Topics: Introduction Errors and Error handling Exceptions Types of Exceptions Coding Exceptions Summary.
Chapter 15: Exception Handling C++ Programming: Program Design Including Data Structures, Fifth Edition.
Exceptions in Java. What is an exception? An exception is an error condition that changes the normal flow of control in a program Exceptions in Java separates.
Error Handling Tonga Institute of Higher Education.
Programming & Debugging. Key Programming Issues Modularity Modifiability Ease of Use Fail-safe programming Style Debugging.
DT228/3 Web Development JSP: Actions elements and JSTL.
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
JSP Directive and Objects. JSP Directives As discussed before There are 3 types of elements in JSP Directive Elements Scripting Elements Standard Action.
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
COMPUTER PROGRAMMING I SUMMER Understand Different Types of Programming Errors.
ECE122 L23: Exceptions December 6, 2007 ECE 122 Engineering Problem Solving with Java Lecture 24 Exceptions.
Exceptions and Error Handling. Exceptions Errors that occur during program execution We should try to ‘gracefully’ deal with the error Not like this.
Cool CF Debugging Shlomy Gantz 07/29/01CF_ODYSSEY.
JSP: Actions elements and JSTL
Indexer AKEEL AHMED.
Chapter 14: Exception Handling
Invoking Java Code from JSP
Debugging and Handling Exceptions
Presentation transcript:

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 fix syntax errors 2) Deal with runtime errors

Some Tips on errors and debugging in JSP Typical errors are 1. - wrong or missing brackets (e.g. ${ …} for EL) 2. - Tags not closed either with a closing tag (e.g. …. OR if an empty element 3. taglib directive missing  tags won’t be recognised 4.“ “ incorrectly used when setting values of an action

Some Tips on errors and debugging in JSP Compilation errors generated by Apache Tomcat vary in helpfulness, depending on the error If location of error is given e.g. ……. /ch9/error.jsp (0, 33) unterminated tag The first index (0) refers to the line number in the JSP page, 0 is the first line number. The second index “33” refers to the position within the line. Not all errors are so meaningful To debug a JSP, can use actions to output values if you need to see the values of variables

Runtime errors In java – have used try/catch blocks to trap errors gracefully Two techniques are useful in JSP (1) Catch exceptions (similar to java). (2) Using error pages - your application will default to an error page specified by you, if an uncaught exception is encountered

Runtime errors – catching exceptions JSTL provides a action to catch exceptions that occur when a JSP page is run Similar to java.. but no ‘try’ needed  is placed around the code that is likely to cause the error The tag provides an attribute “var” which you must name in order to hold the error message. Example: Error msg put in here if error thrown

Runtime errors – catching exceptions To then test if an error has occurred… just check the contents of your error message variable: Example: Checks the error variable to see if an error occurred

JSP page using c:catch Enter two numbers and click ‘divide’ to get result of number 1 / number 2

Please enter numbers Number 1: Number 2: JSP page using c:catch -  continued overleaf

JSP page using c:catch

doesn’t allow you to specify a specific exception – just allows errors to be handled gracefully within the page Prevents an un-userfriendly exception stack trace from being displayed to the user JSP page using c:catch

Error page Can specify a default error page for your application When an unhandled error occurs (i.e. not handled by c:catch, this page will be displayed Use page directive attribute “errorpage” to specify a default error page that should be display each time an unhandled runtime error occurs page errorPage = “errorpage.jsp”

Error page Must have error page (e.g errorpage.jsp) available. This error page must declare itself as an error, also using page directive: page iserrorPage = “true”

Runtime errors Using JSTL – Runtime errors are less likely. JSTL tries to anticipate or handle the error gracefully.. e.g. if Divide by zero error is encountered – JSTL will simply print out a result as “Divide by zero” To find the runtime errors that may occur, test your code!

Anticipate errors Design your code so that errors are anticipated and managed before they occur E.g. User registration – adding a new user. User is identified by username which they enter before adding the user, check whether the username has already been used before..how?