Solved

Opening Excel in JSP - Does it Require Weblogic server Setting

Posted on 2004-04-28
8
15,980 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Most of the developers using Tomcat find it easy to configure the datasource in Server.xml and use the JNDI name in the code to get the connection.  So the default connection pool using DBCP (or any other framework) is made available and the life go…
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 …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

864 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

21 Experts available now in Live!

Get 1:1 Help Now