JSP로 xls등 파일열기

기타 | 2007. 12. 21. 14:09
Posted by 시반

Html 파일에서 다음과 같이 contentType을 지정해서  해당 파일로 열수 있다.

<meta http-equiv="Content-Type" content="application/vnd.ms-excel;charset=euc-kr">

 

하지만 JSP에서..

<%

    response.setHeader("Content-Type", "application/x-msdownload");
    response.setHeader("Content-Disposition", "attachment;filename=파일명;");

    response.setHeader("Content-Description", "JSP Generated Data");
%>

<%=파일내용출력%>

 

이렇게 하면 아래 화면과 같이 파일을 열기전에 download 여부를 확인하는 창이 뜨게 된다.

 

##########0*

 

 

이하는 File별 contentType을 정의한 리스트입니다.

 

application/acad
AutoCAD drawing files
dwg

application/clariscad
ClarisCAD files
ccad

application/dxf
DXF (AutoCAD)
dxf

application/msaccess
Microsoft Access file
mdb

application/msword
Microsoft Word file
doc

application/octet-stream
Uninterpreted binary
bin

application/pdf
PDF (Adobe Acrobat)
pdf

application/postscript
PostScript, encapsulated PostScript,
Adobe Illustrator
ai, ps, eps

application/rtf
Rich Text Format file
rtf rtf

application/vnd.ms-excel
Microsoft Excel file
xls

application/vnd.ms-powerpoint
Microsoft PowerPoint file
ppt

application/x-cdf
Channel Definition Format file
cdf

application/x-csh
C-shell script
csh csh

application/x-dvi
TeX
dvi dvi dvi

application/x-javascript
JavaScript source file
js

application/x-latex
LaTeX source file
latex

application/x-mif
FrameMaker MIF format
mif

application/x-msexcel
Microsoft Excel file
xls

application/x-mspowerpoint
Microsoft PowerPoint file
ppt

application/x-tcl
TCL script
tcl

application/x-tex
TeX source file
tex

application/x-texinfo
Texinfo (emacs)
texinfo, texi

application/x-troff
troff file
t, tr, roff t, tr, roff

application/x-troff-man
troff with MAN macros
man

application/x-troff-me
troff with ME macros
me

application/x-troff-ms
troff with MS macros
ms

application/x-wais-source
WAIS source file
src

application/zip
ZIP archive
zip

audio/basic
Basic audio (usually m-law)
au, snd

audio/x-aiff
AIFF audio
aif, aiff, aifc

audio/x-wav
Windows WAVE audio
wav

image/gif
GIF image
gif

image/ief
Image Exchange Format file
ief

image/jpeg
JPEG image
jpeg, jpg jpe

image/tiff
TIFF image
tiff, tif

image/x-cmu-raster
CMU Raster image
ras

image/x-portable-anymap
PBM Anymap image format
pnm

image/x-portable-bitmap
PBM Bitmap image format
pbm

image/x-portable-graymap
PBM Graymap image format
pgm

image/x-portable-pixmap
PBM Pixmap image format
ppm

image/x-rgb
RGB image format
rgb

image/x-xbitmap
X Bitmap image
xbm

image/x-xpixmap
X Pixmap image
xpm

image/x-xwindowdump
X Windows Dump (xwd)
xwd

multipart/x-gzip
GNU ZIP archive
gzip

multipart/x-zip
PKZIP archive
zip

text/css
Cascading style sheet
css

text/html
HTML file
html, htm

text/plain
Plain text
txt

text/richtext
MIME Rich Text
rtx

text/tab-separated- values
Text with tab-separated values
tsv

text/xml
XML document
xml

text/x-setext
Struct-Enhanced text
etx

text/xsl
XSL style sheet
xsl

video/mpeg
MPEG video
mpeg, mpg, mpe

video/quicktime
QuickTime video
qt, mov

video/x-msvideo
Microsoft Windows video
avi

video/x-sgi-movie
SGI movie player format
movie

 
블로그 이미지

시반

시반(詩伴)이란 함께 시를 짓는 벗이란 뜻을 가지고 있습니다. 함께 나눌수 있는 그런 공간이길 바라며...

카테고리

분류 전체보기 (233)
개발 이야기 (73)
WEB2.0 (57)
DB2 (24)
MySQL (6)
오라클 (26)
기타 (44)
취미 (0)
잡담 (2)