본문 바로가기
Develop/Java Server Page

URL/URI

by jaekk 2018. 7. 19.
ex) localhost/page/list.do?type=aa


URL: localhost/page/list.do?type=aa
URI: /page/list.do

contextPath: /page 


서블릿에서의 핵심 코드


1
2
3
4
5
String command = request.getRequestURI();
 
if(command.indexOf(request.getContextPath()) == 0) {
    command = command.substring(request.getContextPath().length());
}
cs


경로 구하기


1. getRequestURI() 메서드를 이용하여 URI를 구한다.

2. 구한 URI에서 getContextPath() 메서드로 설정 경로의 index번호부터 나머지의 문자를 자른다.


'Develop > Java Server Page' 카테고리의 다른 글

비동기통신  (0) 2018.07.20
웹 어플리케이션 배포하기  (0) 2018.07.20
서블릿  (1) 2018.07.19
회원가입창 로그인창 만들기  (0) 2018.07.17
JDBC프로그래밍  (0) 2018.07.16

댓글