Solved

Opening Excel in JSP - Does it Require Weblogic server Setting

Posted on 2004-04-28
8
15,984 Views
Last Modified: 2013-12-10
Hai
I open a Excel file in Jsp.

The first Page has a javascript to open a new window with a jsp page passing the file name and location.

the jsp page opened in the new browser has the following code.

<%@ page language="java" contentType="text/html;charset=euc-kr"%>
<%
String file = (String)request.getParameter("File");
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition","attachment;filename="+file);
%>


Excel is opened but it is empty document.

What should i do in the above code or with the weblogic setting to see the contents of the Excel file

I am using weblogic 6.1 server does it require any mime setting?

Rgds
Mani
0
Comment
Question by:jackiemani
8 Comments
 
LVL 4

Expert Comment

by:illusionz70
ID: 10947501
you will have to make the following settings in web.xml.
if you are running a proxy make these settings in the proxy(since .xls are static i presume) o therwise make them in weblogic.

 <servlet>
    <servlet-name>FileServlet</servlet-name>
    <servlet-class>weblogic.servlet.FileServlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>FileServlet</servlet-name>
    <url-pattern>*.xls</url-pattern>
  </servlet-mapping>

cheers
0
 

Author Comment

by:jackiemani
ID: 10954740
Hai i dont use a servlet in my code,
I use two JSP pages first one invoking by a href and with javascript window.open the other jsp the code of which i have mentioned above.

Is it still possible to use the above as i dont have any servlet in the name of FileServlet.I am new to Server setting side.

Rgds
Mani
0
 
LVL 4

Expert Comment

by:illusionz70
ID: 10956698
yes it still possible ..update ur web.xml with the following settings.FileServlet is provided by weblogic itself.the code just lets weblogic know that it handles .xls files itself
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 23

Assisted Solution

by:rama_krishna580
rama_krishna580 earned 30 total points
ID: 10962070
see this..

Hi,
May be this could help:-
The points given below gives idea about how to display the report or
static data  for which data is retrieved in the servlet and printed
through jsp.

1.      The conversion of report into excel is done by changing the
setContentType of response
in the servlet.The mimeType should be added in mimeTypes of application
server corresponding to the string given in setContentType.The setHeader
is for default file
name for excel    
Example:
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition","attachment;filename=file.xls")
;
Setting Mime type in server(Weblogic):
weblogic.httpd.mimeType. application/vnd.ms-excel =xls

2.      In IE  the excel is directly downloaded and the user explicitly
saves in the local system.In  Netscape the user is given the option to
open the file or save it to the local system

3.      Note:
1) It is better if the whole information of the report in a single
table.
2) If the application requires both html and excel format of the same
report to be displayed on certain conditions, it is better to have two
different jsps one for html and other for Excel since the formatting is
different

best of luck..

R.K
0
 
LVL 4

Accepted Solution

by:
illusionz70 earned 25 total points
ID: 10975953
aaah... yah Mime needs to be set as welll.....

 <mime-mapping>
    <extension>xls</extension>
    <mime-type>application/vnd.ms-excel</mime-type>
  </mime-mapping>
0
 

Expert Comment

by:pratikbm
ID: 21381213
I am yet not able to open the excel it opens a blank file
0
 

Expert Comment

by:pratikbm
ID: 21381221
<%@ page language="java" contentType="text/html;charset=euc-kr"%>
<%

response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition","attachment;filename=temp.xls");
%>


Above is the code I am using it opens the file but no content inside it

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Tivoli 2 127
activemq cluster 1 237
REST Service will not deploy to Glassfish (ORA-01882: timezone region not found) 1 202
constructor overloading 2 81
This article is about some of the basic and important steps to be used to improve the performance in web-sphere commerce application development. 1) Always leverage the Dyna-caching facility provided by the product 2) Remove the unwanted code …
There are numerous questions about how to setup an IBM HTTP Server to be administered from WebSphere Application Server administrative console. I do hope this article will wrap things up and become a reference for this task. You need three things…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now