HTTP 헤더에 보면, Referer라는 헤더가 존재한다. 이는 브라우져가 가지고 있다가 요청시 사용하게 된다.
예를 들어 어느 웹서버로부터 우리 서버가 노출되고 있는지 알고 싶을 때, 또는 쇼핑 서버로부터 연동하는 웹서버의 경우 유용하게 써먹어 볼 수 있다.
(HttpServeltRequest request)
String ref = request.getHeader("referer");
if ("google".indexOf(ref)) {
// DB 저장.
}
javax.servlet.http
Interface HttpServletRequest
getHeader
public java.lang.String getHeader(java.lang.String name)
- Returns the value of the specified request header as a
String
. If the request did not include a header of the specified name, this method returnsnull
. The header name is case insensitive. You can use this method with any request header. -
-
- Parameters:
name
- aString
specifying the header name- Returns:
- a
String
containing the value of the requested header, ornull
if the request does not have a header of that name
'web' 카테고리의 다른 글
SSL (c, java) (0) | 2007.09.28 |
---|---|
아파치 래퍼럴 (apache referal) (0) | 2007.09.27 |
HTTPClient을 이용한 로그인 테스트 (0) | 2007.09.19 |
jstl중 메모리 릭 발생 관련 (ExpressionEvaluatorManager) (0) | 2007.09.14 |
java.net.NoRouteToHostException: No route to host 해결 (0) | 2007.09.04 |