Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Opening Excel in JSP - Does it Require Weblogic server Setting

Posted on 2004-04-28
8
Medium Priority
?
16,050 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 23

Assisted Solution

by:rama_krishna580
rama_krishna580 earned 90 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 75 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This exercise is about for the following scenario: Dmgr and One node with 2 application server. Each application server contains it owns application. Application server name as follows server1 contains app1 server2 contains app1 Prereq…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

705 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