티스토리 뷰
JSTL Core - catch tag
페이지내에서 발생하는 에러에 대한 처리 방식이다.
Attributes
Name | Dynamic | Decription | Type | Required |
---|---|---|---|---|
var | false | Name of the exported scoped variable for the exception thrown from a nested action. The type of the scoped variable is the type of the exception thrown. |
String | No |
How to use
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>JSTL remove tag example</title>
</head>
<body>
<c:catch var="umejintanException">
<%
int i= (int) (Math.random() * 10);
if (i < 5 ) throw new Exception(); %>
</c:catch>
<c:choose>
<c:when test="${!empty umejintanException}">
Execption is thrown.
</c:when>
<c:otherwise>
This is fine to work.
</c:otherwise>
</c:choose>
</body>
Description
<c:catch> 는 페이지내에서 발생하는 에러를 핸들링 할 수 있으며, 발생한 에러에 대해서 복수의 작업을 진행할 수 있다. <c:catch> 는 pageScope 의 value로 저장되며, 페이지를 벗어나면 저장된 데이터는 삭제된다. 에러 발생 체크는 <c:catch> 로 영역을 지정 할 수 있으며, 에러 발생 여부에 대해서 확인하여 관련된 처리를 진행하면 된다.
Reference
'JSTL' 카테고리의 다른 글
[JSTL] Core :: choose tag (0) | 2016.08.08 |
---|---|
[JSTL] Core - if tag (0) | 2016.08.07 |
[JSTL] Core :: remove tag (0) | 2016.08.04 |
[JSTL] Core :: set tag (0) | 2016.08.04 |
[JSTL] Core :: out tage (0) | 2016.08.04 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- IO
- 라이브아카데미
- forToken
- Field
- reflection
- 자바
- 파일
- java
- BufferedReader
- 임시파일
- isDirectory
- FileInputStream
- syntax
- choose
- FOUND_ROW
- 소스코드
- select
- IF
- foreach
- Rowcount
- jstl
- Set
- BufferedWriter
- JSP
- InputStreamWriter
- InputStreamReader
- catch
- file
- remove
- highlight.js
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함