// http:// 로 들어왔을 경우 https://로 redirect

String url = request.getRequestURL().toString();


// http:// 로 시작하고, url에 localhost와 test가 들어 있지 않을 경우에만 redirect

if( url.startsWith("http://") && ( url.indexOf("localhost") < 0 && url.indexOf("test") < 0) ) {

url = url.replaceAll("http://", "https://");

response.sendRedirect(url);

}





톰캣 올려서 localhost로 접근하거나, 테스트 서버에 배포하여 url에 test 구문이 들어가지 않은 

실제 서버에 접근했을 때, 


http:// 로 시작한 url일 경우 https:// 로 변경하여 redirect






출처: http://blog.naver.com/PostView.nhn?blogId=dryice80&logNo=80094262790

'Web > JSP' 카테고리의 다른 글

package javax.servlet does not exist 오류 해결방법  (2) 2013.09.17
Posted by 야동우
,

통합개발툴이 아닌 콘솔에서 javac로 컴파일 하려는데, 아래 에러메세지가 뜬다.


문제)

error: package javax.servlet does not exist

error: package javax.servlet.annotation does not exist

error: package javax.servlet.http does not exist

등등..



교재에서 시키는대로 CLASSPATH 에 [톰캣설치디렉터리]\lib\servlet-api.jar 를 입력해주어도 같은 오류가 계속 발생!


하는 수 없이 상기 파일을 [자바설치디렉터리]\jre\lib\ext 폴더 아래로 복사해주었더니 해결.


해결)

[톰캣설치디렉터리]\lib\servlet-api.jar 파일 복사 후,

[자바설치디렉터리]\jre\lib\ext 폴더로 붙여넣기


'Web > JSP' 카테고리의 다른 글

JSP] http로 접근할 경우 https://로 redirect  (0) 2013.12.17
Posted by 야동우
,