반응형

기본적으로 HttpSessionListener를 구현(Implements)하여 세션이 생성 되는 시점과 세션이 사라지는 시점을 가지고 올 수 있다.

세션을 생성 되는 시점에 DB나 특정 Static 변수에 세션 정보를 저장 하고 세션이 종료될 때 그 세션 정보를 지워 줌으로써

해당 세션의 중복 로그인을 막을 수 있으며 현재 접속중이 접속자 정보를 가지고 올 수 있다.

package com.moainfo.http.session;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class MoaSessionListener implements HttpSessionListener
{
 public void sessionCreated(HttpSessionEvent se)
 {
  HttpSession session = se.getSession();
  System.out.println("Create session : " + session.getId());
 }
 public void sessionDestroyed(HttpSessionEvent se)
 {
  HttpSession session = se.getSession();
  System.out.println("Close session : " + session.getId());
  
 }
}

 


출처 - http://definejava.net/


===================================================================================


HttpSessionBindingListener vs HttpSessionListener

HttpSessionBindingListener 는 이 인터페이스를 임플리먼츠한 객체를 세션에 바인딩 시키거나 언바인딩 될때 이벤트가 발생합니다. 반면에 HttpSessionListener 인터페이스는 톰캣의 web.xml에 리스너로서 등록을 하면 해당사이트에서 세션이 생성될때 ,글구 소멸될때 발생합니다. 순수한 세션 카운팅을 할때 꼭 필요합니다. ^^;;


출처 - http://www.okjsp.pe.kr/seq/28283


반응형
반응형

무슨 이야기인가 하면 예를 들어 webmini.net 로 접속했을때와 www.webmini.net 그리고 카페24 호스팅 같은 경우 backzzanggu.cafe24.com 으로 접속했을때 자동으로 www.webmini.net 한곳으로 접속되게 하는 팁입니다.

알ftp에서 숨김파일로 되어있어 보이지 않는 파일을 상단메뉴 옵션 > 환경설정에서 숨긴파일을 볼수 있게 설정한후
.htaccess 파일을 메모장으로 연후 2~4 줄에 아래소스를 추가해 줍니다.

RewriteCond %{HTTP_HOST} !^www\.webmini\.net$ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*)$ http://www\.webmini\.net/$1 [L,R]

쉽게 말하면 RewriteEngine On 아래에 위에 소스를 추가하는 것입니다.
그럼 www 붙히지 않고 접속해도 자동으로 www 가 붙어서 연결되는걸 확인할수 있습니다.
주소는 각자 구매하신 도메인 주소로 수정하세요.(아래소스 참고)

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.webmini\.net$ [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*)$ http://www\.webmini\.net/$1 [L,R]
</IfModule>


ps. 혹시 모르니 백업해두시기 바라며, cafe24 같은 경우 이상없이 접속 되었습니다.

http://webmini.net
http://backzzanggu.cafe24.com


위 주소로 접속해 보세요.^^

이렇게 해줘야 webmini.net 으로 로그인했을때 www.webmini.net 으로 들어가면 로그인이 풀려있는것을 방지할수도 있답니다.

출처 : [XE(XpressEngine)] : 웹미니 (http://www.webmini.net/?mid=xe&document_srl=17467)

 

 

 

+ 자바스크립트로 처리시

<script  language="JavaScript" type="text/javascript">
 var host = location.host.toLowerCase();
 var currentAddress = location.href;
 if (host.indexOf("www") == -1)
 {
  currentAddress = currentAddress.replace("//","//www.");
  location.href = currentAddress;
 }
</script>

 

반응형

'웹프로그래밍' 카테고리의 다른 글

Huzy TOOLS 를 시작.  (0) 2024.01.02
Conditional comments with IE  (0) 2015.04.17
MySQL 수정  (0) 2014.06.28
웹폰트 완벽 사용법? (woff, eot)  (0) 2014.03.08
XE 템플릿 구문  (0) 2014.02.18
반응형

$functionName() or call_user_func($functionName)

반응형
반응형
훈민정음 반포 569돌을 맞이해서 자그마한 선물을 마련했습니다. 

작년 7월에 발표한 Noto Sans CJK 글꼴을 이제 여러분의 웹 사이트에서도 마음대로 쓸 수 있습니다. Noto Sans CJK 글꼴 패밀리 가운데 한국어 전용인 Noto Sans KRGoogle Fonts Early Access를 통해 제공합니다. Noto Sans KR은 현대 한국어 뿐 아니라, 옛한글도 완벽하게 지원하고 총 6가지 굵기(weight) 중에 마음대로 골라 쓸 수 있습니다. ( 데모 페이지 )



구글은 웹과 인터넷에서 한글을 보다 아름답고 다양하게 표현할 수 있도록 많은 노력을 기울여 왔습니다. 그 일환으로 국내 글꼴 제작사가 만든 여러 종류의 한국어 글꼴을 구글 웹 폰트 서비스에 더해 왔습니다.

이제 Noto Sans KR을 11번째 한국어 웹 글꼴로 내놓습니다.

웹 디자이너 여러분, 어떤 플랫폼이나 화면 배율에서도 미려하고, 웹 접근성도 우수하며 검색 엔진 친화적인 웹 사이트 디자인을 원하신다면 웹 글꼴을 적용해 보세요.

어떻게 쓰냐고요? 매우 간단합니다. 여러분의 웹 페이지 스타일 시트에 다음을 추가하시고, 글꼴로 'Noto Sans KR'을 지정하세요.



font-family: 'Noto Sans KR', sans-serif;



한중일 다국어 페이지를 만드신다고요? 문제 없답니다. html에서 콘텐츠의 언어를 'lang' 태그로 명시하고 다음을 스타일 시트에 더하시면 됩니다.



/*  한국어 */
:lang(ko) {
 font-family: 'Noto Sans KR', sans-serif;
}

/* 일본어 */
:lang(ja) {
 font-family: 'Noto Sans JP', sans-serif;
}

/* 중국어 (간체) */
:lang(zh-Hans) {
 font-family: 'Noto Sans SC', sans-serif;
}

... 생략 ...

<body>
.... 생략 ....
<div lang="ko"> ... 한국어 콘텐츠</div>
<div lang="ja"> ... 일본어 콘텐츠</div>
<div lang="zh-Hans"> ... 중국어 간체 콘텐츠</div>

 

출처: http://googledevkr.blogspot.kr/2015/10/noto.html

반응형
반응형

Your problem is not actually specific to ejs.

2 things to note here

  1. style.css is an external css file. So you dont need style tags inside that file. It should only contain the css.

  2. In your express app, you have to mention the public directory from which you are serving the static files. Like css/js/image

it can be done by

app.use(express.static(__dirname + '/public'));

assuming you put the css files in public folder from in your app root. now you have to refer to the css files in your tamplate files, like

<link href="/css/style.css" rel="stylesheet" type="text/css">

Here i assume you have put the css file in css folder inside your public folder.

So folder structure would be

.
./app.js
./public
    /css
        /style.css

 

반응형
반응형

I know this is an old thread, but the selected answer isn't clear enough for me.

The point is the delete operator removes a property from an object. It cannot remove a variable. So the answer to the question depends on how the global variable or property is defined.

(1) If it is created with var, it cannot be deleted.

For example:

var g_a = 1; //create with var, g_a is a variable 
delete g_a; //return false
console.log(g_a); //g_a is still 1

(2) If it is created without var, it can be deleted.

g_b = 1; //create without var, g_b is a property 
delete g_b; //return true
console.log(g_b); //error, g_b is not defined

Technical Explanation

1. Using var

In this case the reference g_a is created in what the ECMAScript spec calls "VariableEnvironment" that is attached to the current scope - this may be the a function execution context in the case of using var inside a function (though it may be get a little more complicated when you consider let) or in the case of "global" code the VariableEnvironment is attached to the global object (often window).

References in the VariableEnvironment are not normally deletable - the process detailed in ECMAScript 10.5 explains this in detail, but suffice it to say that unless your code is executed in an eval context (which most browser-based development consoles use), then variables declared with var cannot be deleted.

2. Without Using var

When trying to assign a value to a name without using the var keyword, Javascript tries to locate the named reference in what the ECMAScript spec calls "LexicalEnvironment", and the main difference is that LexicalEvironments are nested - that is a LexicalEnvironment has a parent (what the ECMAScript spec calls "outer environment reference") and when Javscript fails to locate the reference in a LexicalEenvironment, it looks in the parent LexicalEnvironment (as detailed in 10.3.1 and 10.2.2.1). The top level LexicalEnvironment is the "global environment", and that is bound to the global object in that its references are the global object's properties. So if you try to access a name that was not declared using a var keyword in the current scope or any outer scopes, Javascript will eventually fetch a property of the window object to serve as that reference. As we've learned before, properties on objects can be deleted.

Notes

  1. It is important to remember that var declarations are "hoisted" - i.e. they are always considered to have happened in the beginning of the scope that they are in - though not the value initialization that may be done in a var statement - that is left where it is. So in the following code, a is a reference from the VariableEnvironment and not the window property and its value will be 10 at the end of the code:

    function test() { a = 5; var a = 10; }

  2. The above discussion is when "strict mode" is not enabled. Lookup rules are a bit different when using "strict mode" and lexical references that would have resolved to window properties without "strict mode" will raise "undeclared variable" errors under "strict mode". I didn't really understand where this is specified, but its how browsers behave.

 

반응형
반응형

 

preg_match_all('/(\w+)=([^&]+)/', $_SERVER["QUERY_STRING"], $pairs);
  $_GET = array_combine($pairs[1], $pairs[2]);
반응형
반응형

jQuery에서 for, while 문과 비슷한 역할을 하는 each 메소드 사용 시

break, continue와 같은 프로세스를 수행해야 할 때가 있다.

 

그럴 때 return true;continue와 같은 역할을, return false; break와 같은

역할을 수행한다.

 

예제 >>

 

$('#loop').each ( function() {

  if ( i==0 ) return true; // continue;

  else return false; // break;

} );

 

 

출처 :http://dhplanner.blogspot.kr/2009/06/jquery-each-%EB%A9%94%EC%86%8C%EB%93%9C-%EC%82%AC%EC%9A%A9%EC%8B%9C-break-continue-%EC%82%AC%EC%9A%A9.html

반응형

+ Recent posts