sitelink1 | http://blog.naver.com/shreds?Redirect=Log&logNo=89747030 |
---|---|
sitelink2 | http://www.iana.org/assignments/media-types/text/index.html |
sitelink3 | |
sitelink4 | |
sitelink5 | |
sitelink6 |
1. setContentType 메서드
public void setContentType(java.lang.String type)
- Sets the content type of the response being sent to the client, if the response has not been committed yet. The given content type may include a character encoding specification, for example,
text/html;charset=UTF-8
. The response's character encoding is only set from the given content type if this method is called beforegetWriter
is called.This method may be called repeatedly to change content type and character encoding. This method has no effect if called after the response has been committed. It does not set the response's character encoding if it is called after
getWriter
has been called or after the response has been committed.Containers must communicate the content type and the character encoding used for the servlet response's writer to the client if the protocol provides a way for doing so. In the case of HTTP, the
Content-Type
header is used. - Parameters:
type
- aString
specifying the MIME type of the content
2. MIME Type
text/html
audio/mpeg
image/bmp
image/jpeg
application/pdf
application/java
application/jar
application/x-zip
application/msword
application/msaccess
application/vnd.ms-excel
application/vnd.ms-powerpoint
application/octet-stream
마지막에 굵게 표기되어 있는 octet-stream 이라는 놈은 이름 그대로 8비트 바이너리 배열을 의미하며 http나 이메일상에서 application 형식이 지정되지 않았거나 형식을 모를때 사용합니다. 결국 브라우저는 octet-stream 으로 MIME 타입이 지정된 경우 단지 바이너리 데이터로서 다운로드만 가능하게 처리하게 됩니다.
※ setContentType 메소드로 contentType을 지정해 놓고 출력 스트림을 바꾸는 것은 물건을 줬다 뺐는 행위입니다.
즉 setContentType 메소드가 제일 먼저 호출되고 getOutputStream과 같은 출력 스트림 메소드가 사용되어져야 합니다
|