Enumeration paramEnum = request.getParameterNames();
while(paramEnum.hasMoreElements()) {
	String name = (String)paramEnum.nextElement();
	out.println(name);
}
블로그 이미지

디츠

“말은 쉽지, 코드를 보여줘.” “Talk is cheap. Show me the code.” – 리누스 토르발스(Linus Torvalds)

,
1. request.getMethod() 함수를 이용해서 찍어보면 (request 는 HttpServletRequest 클래스의 객체) GET인지, POST인지 확인 할 수 있다.
 
2. request.getMethod().equals("GET")일 경우 GET으로 넘어오는 경우엔 true를 반환하고
request.getMethod().equals("POST")일 경우 POST로 넘어오는 경우엔 true를 반환 하겠죠.
 

 

블로그 이미지

디츠

“말은 쉽지, 코드를 보여줘.” “Talk is cheap. Show me the code.” – 리누스 토르발스(Linus Torvalds)

,

1. Run > Run Confiugrations

- 좌측 트리 메뉴에서 Apache Tomcat 서버 선택(E.g. Tomcat v7.0 Server at localhost)

- (x) = Arguments 탭 메뉴 선택

- VM Arguments (텍스트 박스 영역)

 

2. Arguments 텍스트 박스 가장 하단에 아래 코드를 추가하면 됩니다. 추가한 후 적용(Apply) 해주세요!!

 

3. "-Djava.net.preferIPv4Stack=true"

 

4. 이클립스 재실행

'java, jsp, spring, egov' 카테고리의 다른 글

jsp에서 request의 모든 변수 출력  (0) 2016.02.19
jsp에서 request의 get, post 여부 확인  (0) 2016.02.19
jsp 파일 다운로드  (0) 2016.02.04
모바일 접속 구별  (0) 2015.03.31
mod 함수를 이용한 나누기  (0) 2015.01.17
블로그 이미지

디츠

“말은 쉽지, 코드를 보여줘.” “Talk is cheap. Show me the code.” – 리누스 토르발스(Linus Torvalds)

,
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
 
<%@ page import="java.io.*"%>
<%@ page import="java.text.*" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.net.*" %>
 
<%
    request.setCharacterEncoding("UTF-8");
 
    // 파일 업로드된 경로
    String root = request.getSession().getServletContext().getRealPath("/");
    String savePath = root + "upload";
 
    // 서버에 실제 저장된 파일명
    String filename = "20140819151221.zip" ;
     
    // 실제 내보낼 파일명
    String orgfilename = "테스트.zip" ;
      
 
    InputStream in = null;
    OutputStream os = null;
    File file = null;
    boolean skip = false;
    String client = "";
 
 
    try {

        // 파일을 읽어 스트림에 담기
        try {
            file = new File(savePath, filename);
            in = new FileInputStream(file);
        } catch (FileNotFoundException fe) {
            skip = true;
        }
        
        client = request.getHeader("User-Agent");
 
        // 파일 다운로드 헤더 지정
        response.reset();
        response.setContentType("application/octet-stream");
        response.setHeader("Content-Description", "JSP Generated Data");
 
 
        if (!skip) {
        
            // IE
            if (client.indexOf("MSIE") != -1) {
                response.setHeader ("Content-Disposition", "attachment; filename=" + new String(orgfilename.getBytes("KSC5601"), "ISO8859_1"));
 
            } else {
                // 한글 파일명 처리
                orgfilename = new String(orgfilename.getBytes("utf-8"), "iso-8859-1");
 
                response.setHeader("Content-Disposition", "attachment; filename=\"" + orgfilename + "\"");
                response.setHeader("Content-Type", "application/octet-stream; charset=utf-8");
            }  
             
            response.setHeader("Content-Length", "" + file.length());
 
 
       
            os = response.getOutputStream();
            byte b[] = new byte[(int)file.length()];
            int leng = 0;
             
            while ((leng = in.read(b)) > 0) {
                os.write(b,0,leng);
            }
 
        } else {
            response.setContentType("text/html;charset=UTF-8");
            out.println("<script language='javascript'>alert('파일을 찾을 수 없습니다');history.back();</script>");
 
        }
         
        in.close();
        os.close();
 
    } catch (Exception e) {
      e.printStackTrace();
    }
%>
블로그 이미지

디츠

“말은 쉽지, 코드를 보여줘.” “Talk is cheap. Show me the code.” – 리누스 토르발스(Linus Torvalds)

,
http://moople.tistory.com/128

'java, jsp, spring, egov' 카테고리의 다른 글

이클립스에서 ip 방식 변경(IPv6 -> IPv4)  (0) 2016.02.19
jsp 파일 다운로드  (0) 2016.02.04
mod 함수를 이용한 나누기  (0) 2015.01.17
프롬프트(scan) 입력받기  (0) 2015.01.10
기본 메인 메서드  (0) 2015.01.10
블로그 이미지

디츠

“말은 쉽지, 코드를 보여줘.” “Talk is cheap. Show me the code.” – 리누스 토르발스(Linus Torvalds)

,
public class test {

	public static void main(String[] args) {
		int num = 12345;
		int sum = 0;

		sum = sum + (num / 10000);
		num = num - ((num / 10000) * 10000);

		sum = sum + (num / 1000);
		num = num - ((num / 1000) * 1000);
  
		sum = sum + (num / 100);
		num = num - ((num / 100) * 100);  
  
		sum = sum + (num / 10);
		num = num - ((num / 10) * 10);
  
		sum += num;

		System.out.println("sum = " + sum);

	}

}

'java, jsp, spring, egov' 카테고리의 다른 글

jsp 파일 다운로드  (0) 2016.02.04
모바일 접속 구별  (0) 2015.03.31
프롬프트(scan) 입력받기  (0) 2015.01.10
기본 메인 메서드  (0) 2015.01.10
page utf-8 디렉티브  (0) 2014.09.27
블로그 이미지

디츠

“말은 쉽지, 코드를 보여줘.” “Talk is cheap. Show me the code.” – 리누스 토르발스(Linus Torvalds)

,