'Enumeration'에 해당되는 글 3건

 
  1. 2020.11.22 자바 모든 세션값 출력, Java Session Enumeration PrintAll 1
  2. 2010.10.11 [JAVA/ECLIPSE] 이클립스 에러 Multiple markers at this line, Enumeration cannot be resolved to a variable. 1
  3. 2010.02.11 [JAVA/JSP] JSP Request 객체에서 모든변수 뽑기, 출력, Request, Enumeration
2020. 11. 22. 01:35 PROGRAMMING
자바 모든 세션값 출력, Java Session Enumeration PrintAll

자바에서 세션값 출력

 

Enumeration을 이용해서 세션에 등록한 모든 값을 출력하는 예제 입니다.

Enumeration<String> attributes = request.getSession().getAttributeNames();
while (attributes.hasMoreElements()) {
    String attribute = (String) attributes.nextElement();
    System.err.println(attribute+" : "+request.getSession().getAttribute(attribute));
}

 

 

2010. 10. 11. 16:54 DEV ENVIRONMENT
[JAVA/ECLIPSE] 이클립스 에러 Multiple markers at this line, Enumeration cannot be resolved to a variable.
옛날소스중에 변수명 enum을 사용한 소스가 있으면 나는 에러입니다.
Enumeration 을 가장 많이 사용하는 변수명이 enum일수밖에 없죠. ㅎㅎ

에러가 나는 이유는 JDK 1.5부터 'enum'이 예약어가 됬기 때문입니다.

에러날때 'Multiple markers at this line' 이라고 '이줄에 여러개의 마커가 있습니다.'
실제 에러는 두번째줄
'Enumeration cannot be resolved to a variable.'
'이넘을 해당 변수로 정의할 수 없습니다.'

해결하려면 enum 변수명을 교체하면 됩니다.

2010. 2. 11. 17:12 COMPUTER/JAVA, JSP
[JAVA/JSP] JSP Request 객체에서 모든변수 뽑기, 출력, Request, Enumeration

Request는 페이지에서 넘어오면 생성되는 JAVA객체입니다.
이 문서는 enumeration을 이용해 Request객체 안에 들어있는 모든 변수를 출력하는 예제입니다.

JSP용이므로,
JAVA에서는 out.println대신에 system.out.println을 사용하시면 됩니다.

<%
String query="";
Enumeration enum = request.getParameterNames();
while(enum.hasMoreElements()){  
	String key=(String)enum.nextElement();
	String value=request.getParameter(key);
	query+="&"+key+"="+value;
}
query="?"+query.substring(1);
out.println(query);
%>

최근에 올라온 글

최근에 달린 댓글