Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- express 테스트
- non-blocking
- npm
- nodejs
- 콤마 정규식
- window nodeJs
- 자바스크립트 금액콤마
- express
- nodejs 라우팅
- request.getAttribute
- express 실행
- app.use
- 자바스크립트 콤마
- nodejs express
- nodejs 설치
- nodejs npm
- V8 엔진
- express framework
- NPM 과 Express.js
- app.listen
- npm express
- expressjs
- RequestDispatcher
- Express.js
- 금액콤마
- 숫자콤마
- 콤마 정규표현식
- npm이란
- NodeJS란
- app.get
Archives
- Today
- Total
Heung-9
[JAVA] java 에서 현재 URL 가져오기 본문
java 에서 현재 URL 가져오기
Ex) http://localhost:8080/main/main.do 라는 주소로 화면이 실행되어있다고 가정한다.
request.getRequestURI(); //test/WEB-INF/main/main.jsp (view 파일의 경로) request.getRequestURL(); //http://localhost:8080/test/WEB-INF/main/main.jsp (view파일의 전체경로) request.getServletPath(); //main.jsp (해당 view 파일명)
원래 원하는 출력값은 http://localhost:8080/main/main.do 웹브라우저상의 도메인 주소였는데 requestDispatcher 클래스를 사용하니 도메인주소는 안나오고 내부적으로 가져오는 view 파일의 경로만 출력이됬다.
view 단으로 가기위해서는 requestDispatcher 의 include() 또는 forward() 메소드를 통해서 해당 페이지를 요청하기 때문에 내부적인 경로가 출력이 된것이다.
이유를 찾아보니 Tomcat 5.5 버전부터 getRequestURL() 의 실행이 변경되어 최초의 URL 을 넘겨주지 않고 forward 된 jsp 페이지의 URL을 넘겨주도록 변경이 되었다고 한다.
결론 현재 웹브라우저상의 도메인 주소를 가져오기
request.getAttribute("javax.servlet.forward.request_uri"); request.getAttribute( "javax.servlet.include.request_uri" );
Comments