Solved

Opening Excel in JSP - Does it Require Weblogic server Setting

Posted on 2004-04-28
8
16,009 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

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

Upgrading Tomcat – There are a couple of methods to upgrade Tomcat is to use The Apache Installer is to download and unzip and run the services.bat remove|install Tomcat6 Because of the App that we are working with, we can only use Tomcat 6.…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Suggested Courses

752 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