- web.xml 소스
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID"
version="3.0">
<jsp-config>
<taglib>
<taglib-uri>
/WEB-INF/tlds/el-fun.tld
</taglib-uri>
<taglib-location>
/WEB-INF/tlds/el-fun.tld
</taglib-location>
</taglib>
</jsp-config>
</web-app>
- el-fun.tld 소스
<?xml version="1.0" encoding="euc-kr"?>
<taglib xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
version="2.1">
<description>EL에서 함수실행</description>
<tlib-version>1.0</tlib-version>
<short-name>ELfunctions</short-name>
<uri>/ELFunctions</uri>
<function>
<description>게시판</description>
<name>setData</name>
<function-class>board.BoardDao</function-class>
<function-signature>void setData(board.BoardBean))</function-signature>
</function>
</taglib>
- BoardDao.java 소스 (기존의 insertBoard 메소드를 호출하는 부분만 추가)
// EI를 위한 Insert 메소드
public static void setData(BoardBean bbean){
BoardDao b = new BoardDao();
b.insertBoard(bbean);
}
- BoardWriteProc.jsp 소스
<%@page import="java.util.Calendar"%>
<%@page import="board.BoardDao"%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!-- el-fun.tld를 사용할 수 있게됨 -->
<%@taglib prefix="bdao" uri="/WEB-INF/tlds/el-fun.tld"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<% request.setCharacterEncoding("euc-kr"); %>
<!-- 빈클래스 생성 -->
<jsp:useBean id = "bbean" class = "board.BoardBean"></jsp:useBean>
<!-- 빈클래스에 데이터를 추가 -->
<jsp:setProperty property = "*" name = "bbean"/>
<!-- 데이터를 추가 -->
${bdao:setData(bbean)}
<%response.sendRedirect("BoardList.jsp");%>
</body>
</html>
- 결과