고마구의 개발 블로그
240625 10주차 화요일 - JSP 02 본문
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//forword할때 처음 요청할때의 request객체가 살아있어서 request에 데이터를 담으면 forword된 페이지에서 사용할 수 있다.
//request에 데이터를 담을때 setAttribute(key,value)를 이용하고 읽어올때 getAttribute(key)를 사용한다.
request.setAttribute("name","홍길동");
RequestDispatcher dispatcher=request.getRequestDispatcher("03dispatcher.jsp");
dispatcher.forward(request, response);
}
<body>
업글한 페이지
<br>
setAttribute한 name값은
<%=(String)request.getAttribute("name") %>입니다
</body>
'KDT풀스택과정 공부' 카테고리의 다른 글
240627 10주차 목요일 - JSP 04 (0) | 2024.06.27 |
---|---|
240626 10주차 수요일 - JSP 03 (0) | 2024.06.26 |
240624 10주차 월요일 - JSP 01 (0) | 2024.06.24 |
240621 9주차 금요일 - JAVA 20 (0) | 2024.06.21 |
240620 9주차 목요일 - JAVA 19 (0) | 2024.06.20 |