본문 바로가기
[ java ]

protected void doProcess(HttpServletRequest req, HttpServletResponse resp) throws ServletException,IOException { 뜯어보기

by 히앤님 2022. 10. 17.
반응형
SMALL

컨트롤러에서 요청/응답 처리하는 법

protected void doProcess(HttpServletRequest req, HttpServletResponse resp) throws ServletException,IOException {

하나하나 뜯어보자면,

protected : java 접근자, 같은 폴더(패키지)및 그 클래스를 상속(extends)해서 구현하는 경우 접근이 가능 
void : return 되는 타입이 없음을 의미 
HttpServletRequest,HttpServletResponse : 웹브라우저 URL로 servlet이 요청할 시 요청,응답을 받기 위해 만드는 객체. 매개변수로 가지고 있는거임. WAS가 웹브라우저로부터 Servlet 요청을 받으면 req객체 생성해서 저장하고 resp 객체를 생성해 응답을 담아 servlet에게 반환한다. 
throws ServletException,IOException : java.io.IOException 과 javax.servlet.ServletException 예외를 던져야 합니다. 그냥 서블릿 규칙임.

 

HttpServletRequest 과 HttpServletResponse 메소드 정리

HttpServletRequest 과 HttpServletResponse 메소드 정리 HttpServletRequest 를 간단하게 req라고 해봅시다. req를 사용하면, 값을 받아올 수가 있는데, 회원정보를 보냈다면 req 객체 안에 모든 데이터들이 들어가

heannim-world.tistory.com

 

반응형
LIST

댓글