|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Error Ketika Ingin Menampilkan WordDear rekan-rekan JUG,
Saya butuh bantuan nie.. Saya kan ingin agar user web bisa melihat file attachment (langsung terbuka di window browser). Untuk menampilkan file excel + pdf sudah bisa berjalan dengan baik. Browser terbuka dengan menampilkan isi file dengan benar. Tapi untuk file word (.doc), ada sedikit masalah. Browser terbuka. Isi file tampil, tapi berantakan banget isinya! Muncul karakter-karakter kotak-kotak, symbol, dll yang tidak ada dalam file aslinya. Kemudian jika memilih untuk menyimpan file tersebut, hasilnya juga sama ancurnya. (hiks..) Saya sudah coba bolak-balik tanya ke Om Google, tapi masih belum menemukan solusinya. Code-nya sebagai berikut : if (attachment.getExtention().equalsIgnoreCase("pdf")) { response.setContentType("application/pdf"); } else if ((attachment.getExtention().equalsIgnoreCase("xls")) || (attachment.getExtention().equalsIgnoreCase("xlsx"))) { response.setContentType("application/vnd.ms-excel"); } else if ((attachment.getExtention().equalsIgnoreCase("doc")) || (attachment.getExtention().equalsIgnoreCase("docx"))) { response.setContentType("application/msword"); } ServletOutputStream out = response.getOutputStream(); String fileToOpen = getServlet().getServletContext().getRealPath("\\" + attachment.getIDTrans()) + "\\" + attachment.getFilename() + "." + attachment.getExtention(); FileInputStream fis = new FileInputStream(fileToOpen); BufferedInputStream bis = new BufferedInputStream(fis); BufferedOutputStream bos = new BufferedOutputStream(out); byte[] buff = new byte[2048]; int bytesRead; // Simple read/write loop. while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) { bos.write(buff, 0, bytesRead); } fis.close(); bis.close(); bos.close(); Oh ya, di PC saya ini menggunakan word 97. Mohon petunjuknya. Terima kasih. Putri Chairina http://putrichairina.wordpress.com |
|
|
RE: Error Ketika Ingin Menampilkan WordIni pake plain servet doang yah?
Coba dulu di check version ms word nya... Kalo file nya di generate pake ms word 2000 tapi di buka ke 97 biasa emang rusak... Untuk test streaming nya coba ini code di test untuk write file nya ulang ke HDD... Kalo file nya di buka berantakan juga... yah mungkin salah file input nya... Kalo rapi... mungkin salah streaming nya... check header nya, content disposition nya... Ini emang agak2 klenik neh... Gue juga sekarang lagi masalah sama ginian neh Content disposition nya udah di set as inline... tapi masi kebuka as attachment... Adelwin Handoyo | Senior Consultant - Wholesale Bank Standard Chartered Bank Plaza By The Park #06-00, 51 Bras Basah Road. Singapore (189554) T : (65) 655 72441 | E adelwin.adelwin@... ________________________________ From: jug-indonesia@... [mailto:jug-indonesia@...] On Behalf Of PUTRI CHAIRINA Sent: Tuesday, October 27, 2009 2:45 PM To: jug-indonesia@... Subject: [JUG-Indonesia] Error Ketika Ingin Menampilkan Word Dear rekan-rekan JUG, Saya butuh bantuan nie.. Saya kan ingin agar user web bisa melihat file attachment (langsung terbuka di window browser). Untuk menampilkan file excel + pdf sudah bisa berjalan dengan baik. Browser terbuka dengan menampilkan isi file dengan benar. Tapi untuk file word (.doc), ada sedikit masalah. Browser terbuka. Isi file tampil, tapi berantakan banget isinya! Muncul karakter-karakter kotak-kotak, symbol, dll yang tidak ada dalam file aslinya. Kemudian jika memilih untuk menyimpan file tersebut, hasilnya juga sama ancurnya. (hiks..) Saya sudah coba bolak-balik tanya ke Om Google, tapi masih belum menemukan solusinya. Code-nya sebagai berikut : if (attachment.getExtention().equalsIgnoreCase("pdf")) { response.setContentType("application/pdf"); } else if ((attachment.getExtention().equalsIgnoreCase("xls")) || (attachment.getExtention().equalsIgnoreCase("xlsx"))) { response.setContentType("application/vnd.ms-excel"); } else if ((attachment.getExtention().equalsIgnoreCase("doc")) || (attachment.getExtention().equalsIgnoreCase("docx"))) { response.setContentType("application/msword"); } ServletOutputStream out = response.getOutputStream(); String fileToOpen = getServlet().getServletContext().getRealPath("\\" + attachment.getIDTrans()) + "\\" + attachment.getFilename() + "." + attachment.getExtention(); FileInputStream fis = new FileInputStream(fileToOpen); BufferedInputStream bis = new BufferedInputStream(fis); BufferedOutputStream bos = new BufferedOutputStream(out); byte[] buff = new byte[2048]; int bytesRead; // Simple read/write loop. while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) { bos.write(buff, 0, bytesRead); } fis.close(); bis.close(); bos.close(); Oh ya, di PC saya ini menggunakan word 97. Mohon petunjuknya. Terima kasih. Putri Chairina http://putrichairina.wordpress.com <http://putrichairina.wordpress.com> This email and any attachments are confidential and may also be privileged. If you are not the addressee, do not disclose, copy, circulate or in any other way use or rely on the information contained in this email or any attachments. If received in error, notify the sender immediately and delete this email and any attachments from your system. Emails cannot be guaranteed to be secure or error free as the message and any attachments could be intercepted, corrupted, lost, delayed, incomplete or amended. Standard Chartered PLC and its subsidiaries do not accept liability for damage caused by this email or any attachments and may monitor email traffic. Standard Chartered PLC is incorporated in England with limited liability under company number 966425 and has its registered office at 1 Aldermanbury Square, London, EC2V 7SB. Standard Chartered Bank ("SCB") is incorporated in England with limited liability by Royal Charter 1853, under reference ZC18. The Principal Office of SCB is situated in England at 1 Aldermanbury Square, London EC2V 7SB. In the United Kingdom, SCB is authorised and regulated by the Financial Services Authority under FSA register number 114276. If you are receiving this email from SCB outside the UK, please click http://www.standardchartered.com/global/email_disclaimer.html to refer to the information on other jurisdictions. |
|
|
RE: Error Ketika Ingin Menampilkan WordOia lupa.. maap..
Dulu juga pernah masalah gini nih.. solusi gue sih tambahin content length.. sama buffer size nya di gedein.. Tapi yah itu gue.. waktu ituh temen ada yang kena masalah sama.. tapi ternyata masalah nya dari header nya.. Adelwin Handoyo | Senior Consultant - Wholesale Bank Standard Chartered Bank Plaza By The Park #06-00, 51 Bras Basah Road. Singapore (189554) T : (65) 655 72441 | E adelwin.adelwin@... ________________________________ From: jug-indonesia@... [mailto:jug-indonesia@...] On Behalf Of PUTRI CHAIRINA Sent: Tuesday, October 27, 2009 2:45 PM To: jug-indonesia@... Subject: [JUG-Indonesia] Error Ketika Ingin Menampilkan Word Dear rekan-rekan JUG, Saya butuh bantuan nie.. Saya kan ingin agar user web bisa melihat file attachment (langsung terbuka di window browser). Untuk menampilkan file excel + pdf sudah bisa berjalan dengan baik. Browser terbuka dengan menampilkan isi file dengan benar. Tapi untuk file word (.doc), ada sedikit masalah. Browser terbuka. Isi file tampil, tapi berantakan banget isinya! Muncul karakter-karakter kotak-kotak, symbol, dll yang tidak ada dalam file aslinya. Kemudian jika memilih untuk menyimpan file tersebut, hasilnya juga sama ancurnya. (hiks..) Saya sudah coba bolak-balik tanya ke Om Google, tapi masih belum menemukan solusinya. Code-nya sebagai berikut : if (attachment.getExtention().equalsIgnoreCase("pdf")) { response.setContentType("application/pdf"); } else if ((attachment.getExtention().equalsIgnoreCase("xls")) || (attachment.getExtention().equalsIgnoreCase("xlsx"))) { response.setContentType("application/vnd.ms-excel"); } else if ((attachment.getExtention().equalsIgnoreCase("doc")) || (attachment.getExtention().equalsIgnoreCase("docx"))) { response.setContentType("application/msword"); } ServletOutputStream out = response.getOutputStream(); String fileToOpen = getServlet().getServletContext().getRealPath("\\" + attachment.getIDTrans()) + "\\" + attachment.getFilename() + "." + attachment.getExtention(); FileInputStream fis = new FileInputStream(fileToOpen); BufferedInputStream bis = new BufferedInputStream(fis); BufferedOutputStream bos = new BufferedOutputStream(out); byte[] buff = new byte[2048]; int bytesRead; // Simple read/write loop. while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) { bos.write(buff, 0, bytesRead); } fis.close(); bis.close(); bos.close(); Oh ya, di PC saya ini menggunakan word 97. Mohon petunjuknya. Terima kasih. Putri Chairina http://putrichairina.wordpress.com <http://putrichairina.wordpress.com> This email and any attachments are confidential and may also be privileged. If you are not the addressee, do not disclose, copy, circulate or in any other way use or rely on the information contained in this email or any attachments. If received in error, notify the sender immediately and delete this email and any attachments from your system. Emails cannot be guaranteed to be secure or error free as the message and any attachments could be intercepted, corrupted, lost, delayed, incomplete or amended. Standard Chartered PLC and its subsidiaries do not accept liability for damage caused by this email or any attachments and may monitor email traffic. Standard Chartered PLC is incorporated in England with limited liability under company number 966425 and has its registered office at 1 Aldermanbury Square, London, EC2V 7SB. Standard Chartered Bank ("SCB") is incorporated in England with limited liability by Royal Charter 1853, under reference ZC18. The Principal Office of SCB is situated in England at 1 Aldermanbury Square, London EC2V 7SB. In the United Kingdom, SCB is authorised and regulated by the Financial Services Authority under FSA register number 114276. If you are receiving this email from SCB outside the UK, please click http://www.standardchartered.com/global/email_disclaimer.html to refer to the information on other jurisdictions. |
|
|
Re: Error Ketika Ingin Menampilkan Word2009/10/27 PUTRI CHAIRINA <putri.chairina@...>
> > > > FileInputStream fis = new FileInputStream(fileToOpen); > BufferedInputStream bis = new BufferedInputStream(fis); > BufferedOutputStream bos = new BufferedOutputStream(out); > > byte[] buff = new byte[2048]; > int bytesRead; > // Simple read/write loop. > while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) { > bos.write(buff, 0, bytesRead); > } > > fis.close(); > bis.close(); > bos.close(); > Coba jangan pake BufferedXXStream Langsung aja FileInputStream docs = new FileInputStream("nama file"); Writer writer = response.getWriter(); int data = docs.read(); while(data != -1) { writer.write(data); data = docs.read(); } docs.close(); writer.flush(); writer.close(); -- Endy Muhardin http://endy.artivisi.com Y! : endymuhardin -- life learn contribute -- |
|
|
Re: Error Ketika Ingin Menampilkan Word>
> Oh ya, di PC saya ini menggunakan word 97. > Mohon petunjuknya. Jangan2 yang diupload Word 2000 atau docx dan dibukanya pake word 97? begitu? kalau iya ya, coba dibuka aja dulu file yang diupload itu langsung pake word 97, bisa ga? kalau bisa berart ada yang error dengan proses uploadnya. Kalau nggak bisa dan hasilnya juga seperti itu, hmmm, bukan salah kodenya sepertinya. Tapi salah install word 97-nya, coba install word yang paling baru. ;) -- Senior Engineer @ ArtiVisi Intermedia Java Training Center See our course @ artivisi.com http://ifnu.artivisi.com +62 856 9211 8687 regards |
|
|
Re: Error Ketika Ingin Menampilkan Word [SOLVED]Dear JUGers,
Saya sudah coba saran dari pak Endi dan Adelwin. Tapi tidak berhasil. Solusinya sesuai dengan yang Ifnu sarankan, install Word (Office) yang baru. Sepertinya ada yang library yang hilang/currupt pada Word sebelumnya. Terima kasih untuk jawaban rekan-rekan JUGers. Thanks for saving my day. (^__^) Putri Chairina http://putrichairina.wordpress.com --- In jug-indonesia@..., Ifnu bima <ifnubima@...> wrote: > > > > > Oh ya, di PC saya ini menggunakan word 97. > > Mohon petunjuknya. > > Jangan2 yang diupload Word 2000 atau docx dan dibukanya pake word 97? > begitu? kalau iya ya, coba dibuka aja dulu file yang diupload itu > langsung pake word 97, bisa ga? kalau bisa berart ada yang error > dengan proses uploadnya. Kalau nggak bisa dan hasilnya juga seperti > itu, hmmm, bukan salah kodenya sepertinya. Tapi salah install word > 97-nya, coba install word yang paling baru. ;) > > > -- > Senior Engineer @ ArtiVisi Intermedia > Java Training Center > See our course @ artivisi.com > > http://ifnu.artivisi.com > +62 856 9211 8687 > regards > |
| Free embeddable forum powered by Nabble | Forum Help |