❤️01_Java

httpServletRequest(요청) & httpServletResponse(응답)

roomname-dev 2023. 1. 13. 16:41
728x90

httpServletRequest & httpServletResponse

-> WAS(tomcat서버)가 패킷을 받을때 생성하는 요청객체 & 응답 객체 

 

🎈httpServletRequest
  1. Http프로토콜의 request 정보를 서블릿에게 전달
  2. Header정보, Parameter, Cookie, URI, URL 등의 정보를 읽는 메소드를 가진 클래스
  3. Body의 Stream을 읽어들이는 메소드를 가지고 있음
  4. was(tomcat)가 패킷을 받을때 생성하게 
  5. 요청시 header와 body를 저장 
🎈httpServletResponse
  1. Servlet은 HttpServletResponse객체에 Content Type, 응답코드, 응답 메시지등을 담아서 전송함

 

🍭기본 URL 정보 

http://127.0.0.1:8080/contextpath/main/main.do?no=1&cn=p0980

 

 

🍭httpServletRequest.getRequestURL()

http://127.0.0.1:8080/contextpath/main/main.do

 

🍭httpServletRequest.getRequestURI()

/contextpath/servlcetpath/main/main.do?


🍭httpServletRequest.getContextPath()

/contextpath


🍭httpServletRequest.getServletPath()

/servlcetpath/main/main.do

 

🍭httpServletRequest.getQueryString()

no=1&cn=p0980

 

🍭httpServletRequest.getServerName()

127.0.0.1


🍭httpServletRequest.getServerPort()

8080

 

 
728x90