Solved

Opening Excel in JSP - Does it Require Weblogic server Setting

Posted on 2004-04-28
8
15,964 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

-Xmx and -Xms are the two JVM options often used to tune JVM heap size.   Here are some common mistakes made when using them:   Assume BigApp is a java class file for the below examples. 1.         Missing m, M, g or G at the end …
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

20 Experts available now in Live!

Get 1:1 Help Now