블로그 이미지
암초보

calendar

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

Notice

Tag

04-26 02:13

'프로그래밍/Servlet&JSP'에 해당되는 글 4

  1. 2013.11.27 <c:forEach>에서 인덱스 사용법
  2. 2013.05.20 fmt:parseDate 와 fmt:formatDate
  3. 2009.08.05 URLDecoder
  4. 2009.08.04 JSP 쿠키 생성, 삭제
2013. 11. 27. 12:58 프로그래밍/Servlet&JSP

varStatus를 이용한다.

예시)

<c:forEach varStatus="status .........>

${status.index} 또는 ${status.count}

index는 0부터 count는 1부터

'프로그래밍 > Servlet&JSP' 카테고리의 다른 글

fmt:parseDate 와 fmt:formatDate  (0) 2013.05.20
URLDecoder  (0) 2009.08.05
JSP 쿠키 생성, 삭제  (0) 2009.08.04
posted by 암초보
2013. 5. 20. 14:22 프로그래밍/Servlet&JSP
<fmt:parseDate value="${dateStr}" var="dateFmt" pattern="yyyy/MM/dd HH:mm:ss"/>
=> 해당 pattern의 String 타입을 Date 타입으로 변환

<fmt:formatDate value="${date}"  pattern="yyyy/MM/dd HH:mm:ss"/>
=> Date 타입을 해당 pattern 으로 변환


'프로그래밍 > Servlet&JSP' 카테고리의 다른 글

<c:forEach>에서 인덱스 사용법  (0) 2013.11.27
URLDecoder  (0) 2009.08.05
JSP 쿠키 생성, 삭제  (0) 2009.08.04
posted by 암초보
2009. 8. 5. 19:39 프로그래밍/Servlet&JSP
자바스크립트든 어디든, 인코딩 시켜준 타입으로 디코딩 해주면..
한글 안깨짐..

URLDecoder.decode(query, "utf-8);

'프로그래밍 > Servlet&JSP' 카테고리의 다른 글

<c:forEach>에서 인덱스 사용법  (0) 2013.11.27
fmt:parseDate 와 fmt:formatDate  (0) 2013.05.20
JSP 쿠키 생성, 삭제  (0) 2009.08.04
posted by 암초보
2009. 8. 4. 09:02 프로그래밍/Servlet&JSP

저장

 

 Cookie cook1 = new Cookie("name", "kalzas");  //쿠키객체생성

 cook1.setPath="/";  //쿠키가 적용될 웹서버의 url 경로

 cook1.setMaxAge(60*60*24*365); //쿠키가 유지되는 시간(1년) -1일경우 페이지 닫으면 삭제

 cook1.setDomain = "url"; //응답해 줄 도메인 명

 response.addCookie(cook1);  //쿠키를 클라이언트에 세팅

  

 -가져오기

 

 try(

   Cookie[] cookies = request.getCookies();

   for(int i = 0; i < cookies.length; i++){

     out.println(cookies[i].getName() + "은" + cookies[i].getValue() + "입니다.);

   }

 }catch (Exception e){

   out.println(e);

 }

 

 -삭제하기

 

 try{

   Cookie[] cookies = request.getCookies();

   for(int i=0; i< cookies.length; i++){

     cookies[i].setMaxAge(0);

     cookies[i].setPath("/");              // 처음 설정한 Path 로 해줘야 쿠키가 삭제된다!

     response.addCookie(cookies[i]);

   }

   out.println("쿠키가 삭제되었습니다.");

 }catch(Exception e){

   out.println(e);

 }

 

특정 도메인과 연결된 경우에는 그 도메인의 요청에 의해서만 삭제해야 한다.

 

try{

   Cookie[] cookies = request.getCookies();

    for(int i=0; i< cookies.length; i++){

        Cookie cook = cookies[i];

        if(cook.getName().equals("ucc_login")) {

           cook.setPath = "/";

           cook.setDomain = "url"; 

           cook.setMaxAge(0);

           response.addCookie(cook);
        }

     }

} catch(Exception e) {

   out.println(e);

 }

'프로그래밍 > Servlet&JSP' 카테고리의 다른 글

<c:forEach>에서 인덱스 사용법  (0) 2013.11.27
fmt:parseDate 와 fmt:formatDate  (0) 2013.05.20
URLDecoder  (0) 2009.08.05
posted by 암초보
prev 1 next