ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

์นดํ…Œ๊ณ ๋ฆฌ ์—†์Œ

jsp EL02

๐Ÿฉท ์Šˆ ๐Ÿงก 2010. 7. 6. 21:45
728x90
SMALL

package el;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class ElExam01Servlet
 */
public class ElExam01Servlet extends HttpServlet {
 private static final long serialVersionUID = 1L;

 protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  //elexam01
  //ํ™๊ธธ๋™, ์ˆœ๋‘ฅ์ด, ํ† ๋งˆ์Šค, ๋ฝ€๋กœ๋กœ ๊ฐ์ฒด๋“ค์„ ๋งŒ๋“ค์–ด์„œ
  //Request scope ์— ๋‹ด๋Š”๋‹ค.
  //๊ทธ๋ฆฌ๊ณ ๋Š” elExam01.jsp๋กœ ํฌ์›Œ๋”ฉ ํ•œ๋‹ค.
 
  Toy t1 = new Toy();
   t1.setName("๋ฝ€๋กœ๋กœ");
   
  Toy t2 = new Toy();
   t2.setName("ํ† ๋งˆ์Šค");
 
  Dog d = new Dog();
   d.setName("์ˆœ๋‘ฅ์ด");
 
  d.setToys(new Toy[]{t1, t2});
 
  Person p = new Person();
  p.setDog(d);
  p.setName("๊ฐ•ํ˜ธ๋™");
 
  //์ €์žฅ
  request.setAttribute("p", p);
 
  //forwarding
  request.getRequestDispatcher("elexam01.jsp").forward(request, response);
 }
}


#######################################################################
EL ๊บผ๋‚ด๊ธฐ

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!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>
์ถœ๋ ฅ๋  ๋‚ด์šฉ:<br/>

${p.name}์˜ ๊ฐœ  ${p.dog.name}์˜ ์žฅ๋‚œ๊ฐ์€  ${p.dog.toys[0].name}  ,  ${p.dog.toys[1].name} ์ด์ง€์š”.


</body>
</html>
#######################################################################

728x90
LIST
๋Œ“๊ธ€
๊ณต์ง€์‚ฌํ•ญ
์ตœ๊ทผ์— ์˜ฌ๋ผ์˜จ ๊ธ€
์ตœ๊ทผ์— ๋‹ฌ๋ฆฐ ๋Œ“๊ธ€
Total
Today
Yesterday
๋งํฌ
ยซ   2025/04   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
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
๊ธ€ ๋ณด๊ด€ํ•จ
250x250