Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
29 | 30 |
Tags
- sendRedirect
- Java
- DB
- 2021년
- 웹개발자
- set
- servlet
- sql
- 그레이들
- List
- 리액트
- param
- forTokens
- 1회
- forward
- spring
- 스프링
- JSTL
- c:out
- 실기
- IT
- Oracle
- 정보처리기사
- 프로젝트
- el표기법
- MVC
- 프레임워크
- map
- jsp
- 개발자
Archives
- Today
- Total
룽쓰의 개발도구
#JSTL의 redirect를 사용해보자 2 본문
[ A. sendRedirect를 이용해보자 ]
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:url var="next" value="divide.jsp">
<c:param name="num1" value="100"/>
<c:param name="num2" value="0"/>
</c:url>
<c:redirect url="${next }"></c:redirect>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
</body>
</html>
[ B. 보낸 값들의 오류 처리를 해보자 ]
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String str1 = request.getParameter("num1");
String str2 = request.getParameter("num2");
int num1 = Integer.parseInt(str1);
int num2 = Integer.parseInt(str2);
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h3>나눗셈 프로그램(313)</h3>
<c:catch var="ex">
<%
int result = num1/num2;
out.println("나눗셈의 결과는? "+result);
%>
</c:catch>
<c:if test="${ex != null }"> // 문제되는 내용이 있다는 것이다.<br>
익셉션이 발생했습니다.<br>
에러 메세지 :: ${ex.message }<br>
</c:if>
</body>
</html>
'CODE_ZIP > JSTL' 카테고리의 다른 글
#JSTL의 forTokens를 사용해보자 (0) | 2021.04.20 |
---|---|
#JSTL의 forEach를 사용해보자 (0) | 2021.04.20 |
#JSTL의 redirect를 사용해보자 (0) | 2021.04.20 |
#JSTL의 if와 switch 사용법 (0) | 2021.04.20 |
#JSTL의 set랑 out을 사용해보자 (0) | 2021.04.20 |