Skip to content

[6장] 6.2 현재 세션에 저장되어 있는 모든 값을 제거 #3

@Gobukgol

Description

@Gobukgol
public class HttpSession {
    private String id;
    private Map<String, Object> attributes = new HashMap<>();
....
    public void invalidate() {
        attributes.forEach((k, v) -> attributes.remove(k));
    }
}

일단 내가 구현한 것에서 모든 값을 제거하는 부분을 이렇게 Map을 순회하면서 제거하도록 구현했는데

책에서는 HttpSessions의 remove 메소드를 호출해서 아예 HttpSession 객체를 삭제하는 방식으로 구현했어.

내가 한 방식이 틀린걸까??

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions