File Download - 403 problem
Hi Folks,
From long time away from here, I am back.
In my application we are using only ADF Faces. There is a functionality in my application to download some files that have been previously uploaded by any user.
The problem is that the file is not written in a file system. It is inside database.
When the user clicks the download button from an af:table, it starts a method from a backing bean that goes to the database and gets the binary code from there.
It writes the binary array in the response output but since the download has not started by the user the IE 7 and 8 shows the information bar stating that Internet Explorer has blocked this site from download...
I have read that it is a default behaviour from IE7 and 8 when the user does not click in a link directly pointed to a file in a server.
I tried to put the site in Trusted Sites.
The only solution that I found was to enable "Always prompt for downloading". It works but I cannot use this solution since the application is going to run in a big Brazil TV Channel company throughout the country and change it is very difficult.
I so that the difference between the REQUEST HEADERS is the Transfering-Enconding chunked, but it is related to content-lenght, when it is not specified. I tried to specify content-lenght and it did not work.
When I click the bar and choose download file option, it redirects to the same page that I was, changing the afrSOMETHINGMode from 0 to 2 and adding the afrWindow to null.
It gets me a 302, another two other GETs are done witouht success to the context root and at the last one I get the 403.
Does any body have any light?
Thanks in advance.
Hi Mr. Puthanampatti,
I used your above code for a download button.
When I click the button the window will arise and we can download the file.
But after that the button will not become enable.
Normally when the task is over the button will automatically enabled. Butt here it is not happening and we can click the button only one time without refreshing the page.
(I assumed you have used res for HttpServletResponse)
the code I had used is mentioned below. Please tell me what can I do...??
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
HttpServletResponse response = (HttpServletResponse)externalContext.getResponse();
File file = new File(dir1, pdffile1);
BufferedInputStream input = null;
BufferedOutputStream output = null;
try {
input = new BufferedInputStream(new FileInputStream(file), DEFAULT_BUFFER_SIZE);
response.reset();
response.setContentType("application/pdf");
response.setContentLength((int)file.length());
response.setHeader("Content-disposition", "inline; filename=\"" + pdffile1 + "\"");
output = new BufferedOutputStream(response.getOutputStream(), 10240);
byte[] buffer = new byte[10240];
int length;
while ((length = input.read(buffer)) > 0) {
output.write(buffer, 0, length);
output.flush();
} finally {
close(output);
close(input);
facesContext.responseComplete();Thanks a lot.
Dinuka.
Similar Messages
-
Hi java guru's
I'm trying to write a download pgm using servlet and JSP. The actual problem is, when i'm trying to download a file, the output stream writes all the comtent of the file on the browser itself even if it's a .exe file instead of opening a "Save as" dialog box
Can you guru's suggest me a best way to overcome this problem!
Thanks in advanceHello friends,
We can download any files in two ways
1. calling java script function
2. read/write operation(io).
Both codes are working fine. try it and if u face any problem.Please let me know,
Friendly,
Jawahar
bangalore. India
[email protected]
=================================
java script code
==============================
<%
<!-- file relative path is here -->
String path ="/jsp/xxx.xls";
<!-- file name is here -->
String fileName="xxx.xls";
%>
<html>
<head>
<title>Down load forms</title>
</head>
<body onLoad="window.open('<%=path%>');">
<table border="0" align="center" width="100%">
<tr><td height="181"><font face="verdana" color="#5599cc" size="2" align="center">you have selected the file <%=fileName%</font> </td></tr> </table></body></html>
==========================================
Read/write IO operation is here
==========================================
<%
String files = null;
String fileName=null;
<!-- file path is here -->
String file=".... any path";
File f = new File(file);
FileInputStream in = new FileInputStream(f);
int length = (int)f.length();
if(length != 0)
byte[] buf = new byte[length];
ServletOutputStream op = response.getOutputStream();
response.setContentType ("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=\""+fileName+"\"");
while ((in != null) && ((length = in.read(buf)) != -1))
System.out.println("BUFFER $"+buf.length+"$");
System.out.println("Bytes read in: " + Integer.toString(length));
op.write(buf,0, buf.length);
op.close();
%>
<%@ page import="java.io.*,javax.servlet.*,java.util.*,java.sql.* " contentType="text/html" %>
<html>
<head>
<title>Welcome to the download form page</title>
</head>
<body bgcolor=#FFFFFF>
========================================== -
BSP File Download - .TIF problems
Dear all!
I haven't been able to fix this problem,
please see my post for further information. I am using SAP.help coding to display files in BSPs (6.20, "BSP with flow logic" pages used). See the coding below.
Somehow .tif files can not be displayed. Every other mime type works fine.
Thanks,
Chris
Dear all!
In a quite complex file upload and download scenario which works fine we use the following coding to display files received from the backend in our page.
OnInitialization: receives file backend data such as filesize, content(xstring) and mimetype.
This works all fine. Mimetype is delivered correctly.
OnInputProcessing:
This has been taken from the help.sap.com documentation -
runtime->server->response->set_data( mycontent ).
runtime->server->response->set_header_field(
name = 'Content-Disposition'
value = lv_downname ).
runtime->server->response->set_header_field( name = 'Content-Type' value = mymimetype ).
runtime->server->response->set_header_field( name = 'Content-Length' value = myfilesize ).
runtime->server->response->delete_header_field( name = 'Cache-Control' ).
runtime->server->response->delete_header_field( name = 'Expires' ).
navigation->response_complete( ).
RESULT:
the file is displayed fine. When trying to save the displayed file locally on the hard disc, the mimetype is not available. The system (Windows XP) provides only .bmp as file type. Also the context menu entry "Properties" of the displayed file shows NOT AVAILABLE as mimetype.
Is this a common problem? How can I achieve to have the mimetype information available for a save?
Thankx,
Christoph
Message was edited by: Christoph Aschauer
Message was edited by: Christoph Aschauer
Message was edited by: Christoph Aschauer
Message was edited by: Christoph AschauerHi,
I am getting an error, when I try to download the document from the bsp-page.
I have uploaded the document to the server-cache as mentioned above. If I test it on the standalone machine, everything works fine. But when I have to connect to the BSP-Application through an EP I am getting the error:
BSP Exception: Das Objekt test.doc in der URL /sap(bD1kZSZjPTEwMCZwPTM1MjUwJnY9NiUyZTQmaT0xJnM9U0lEJTNhQU5PTiUzYWR0aXRtZXpfVE1FXzA3JTNhLUVVb2Y3MHRUN2JnMGFYMUNLeUVPakRRWmZBTTJVVE5aS21Lc0FRQi1BVFQ=)/bc/bsp/sap/zportal_rueckme/test.doc?sap-syscmd=nocookie ist nicht gültig.
Test.doc is the name of the document I wish to download.
Here comes the sample code.
DATA: cached_response TYPE REF TO if_http_response.
CREATE OBJECT cached_response
TYPE
CL_HTTP_RESPONSE
EXPORTING
add_c_msg = 1.
cached_response->set_data( l_document_x ). " l_document_x is a xstring
cached_response->set_header_field( name =
if_http_header_fields=>content_type
value = l_mime_type ).
cached_response->set_status( code = 200 reason = 'OK' ).
cached_response->server_cache_expire_rel( expires_rel = 180 ).
CONCATENATE
RUNTIME->application_url
'/' l_file_name INTO e_url.
cl_http_server=>server_cache_upload( url = e_url
response = cached_response ).
Later I navigate to that URL:
NAVIGATION->GOTO_PAGE( URL = e_url ).
Any suggestions are appreaciated!
Regards,
Max -
Need urgent help on file download servlet problem in Internet Explore
I have trouble to make my download servlet work in Internet Explore. I have gone through all the previous postings and done some research on the internet, but still can't figure out the solution. <br>
I have a jsp page called "download.jsp" which contains a URL to download a file from the server, and I wrote a servlet (called DownloadServlet) to look up the corresponding file from the database based on the URL and write the file to the HTTP output to send it back to the browser. <br>
the URL in download.jsp is coded like <a href="/download/<%= currentDoc.doc_id %>/<%= currentDoc.name %>">on the browser, it will be sth like , the number 87 is my internal unique number for a file, and "myfile.doc" is the real document name. <br>
in my web.xml, "/download/" is mapped to DownloadServlet <br>
the downloadServlet.java looks like
tem_name = ... //read DB for file name
// set content type
if ( tmp_name.endsWith(".doc")) {
response.setContentType("application/msword");
else if ( tmp_name.endsWith(".pdf")){
response.setContentType("application/pdf");
else if ( tmp_name.endsWith(".ppt")){
response.setContentType("application/vnd.ms-powerpoint");
else if ( tmp_name.endsWith(".xls")){
response.setContentType("application/vnd.ms-excel");
else {
response.setContentType("application/download");
// set HTTP header
response.setHeader("Content-Disposition",
"attachment; filename=\""+tmp_name+"\"");
OutputStream os = response.getOutputStream();
//read local file and write back to browser
int i;
while ((i = is.read()) != -1) {
os.write (i);
os.flush();
Everything works fine in Netscape 7.0, when I click on the link, Netscape prompts me to choose "open using Word" or "save this file to disk". That's exactly the behavior I want. <br>
However in IE 5.50, the behavior is VERY STRANGE.
First, when I click on the URL, the popup window asks me to "open the file from its current location" or "save the file to disk". It also says "You have chosen to download a file from this location, ...(some url).. from localhost"
(1) If I choose "save the file to disk", it will save the rendered "download.jsp" (ie, the currect page with URL I just clicked, which isn't what I want).
(2)But if I choose "open the file from its current location", the 2nd popup window replaces the 1st, which also has the "Open ..." and "Save.." options, but it says "You have chosen to download a file from this location, MYFILE.doc from localhost". (notice it shows the correct file name now)
(3) If I choose "Save..." on the 2nd window, IE will save the correct file which is "myfile.doc"; if I choose "Open ...", a 3rd replaces the 2nd window, and they look the same, and when I choose "Open..." on the 3rd window, IE will use Word to open it.
any ideas?
</a>Did you find a solution to this problem? I've been wrestling with the same issues for the past six months. Nothing I try seems to work. I've tried setting the contentLength(), inline vs. attachments, different write algorythms, etc. I don't get the suggestion to rename the servlet to a pdf file.
-
Problem with file downloads - please help
Good morning. Since upgrading to BT Infinity 2, I have been experiencing the following problems:
Cannot update Sonos firmware to version 5 - download times out and gives error 30
Cannot download most files from safari - all start for the first few kb and then just hang
Cannot download larger PDF files from Mac Mail
These problems manifest themselves over wireless and wired connections, with the BT Homehub 5 and an Asus router. My ipad has no problems when on other networks or if I access my email from my work computer. When talking to BT technical support over the chat facility yesterday the connection dropped once every 10-30 seconds before reconnecting again. All of this leads me to believe that I have an intermittent failure on my broadband connection however BT insist that there is nothing wrong with the line or the router. I have changed channels on my router but this does not seem to make things better. Internet is working fine on all my devices for web browsing - only file downloads experiencing problems.
Please help.Oh sorry, I thought from your description you were using an ASUS connected to the HH5, but it turns out you're using them separately.
Is there a firmware update you can get on the ASUS?
If you found this post helpful, please click on the star on the left
If not, I'll try again -
After downloading a number of 1.0 MB files, the system became very sluggish, and I started to get lots of (Not Responding) messages when trying to download or just use Firefox for browsing. Using Performance Monitor, I observed that the Firefox executable was growing larger and larger - up to as large as 1.2 GB on a system with 2.0 GB memory. Page faults were off the chart.
Looking for a similar problem, I found one that discussed the downloads.sqlite file becoming corrupted. I first noticed that this file was over 600 MB in size, so I deleted it. I then downloaded additional files, and observed that the new downloads.sqlite file would increase in size by about 150% of the size of each file that was downloaded. Once it would get up to 500 MB in size, the system started slowing down again.
I don't know the purpose of this file, but it appears that it keeps a full copy of every file downloaded, which may be the function of a download history file, but it does not seem correct that the file should grow in size without limit, and thus impact the system.
I would also appear that the Firefox executable is trying to read the entire contents of this file each time a new file is downloaded, which does not seem right.
Temporary fix is to periodically delete the downloads.sqlite file when it gets too large and starts impacting performance.. Apparently it is smart enough to open a new file if the old one is not found. I am not sure what the correct behavior for this file should be. Apparently is does not re-initialize when a new Firefox session is initiated.
Please feel free to contact me if more information is desired. I'm not sure what details you might need to troubleshoot this type of problem.Hi Katy, and a warm welcome to the forums!
What is the exact name of the file?
Is it aim.bin?
Which requires either Stuffit Expander, or the Unarchiver to deflate.
http://www.apple.com/downloads/macosx/systemdiskutilities/theunarchiver.html -
I am using Fire Fox 5 beta version. After pausing the long file download, when I press the Resume download button the above message appear each time asking "Contact to Administrator". This problem was not with Fire Fox version 3 and above. Please Help Immediately. Thanks in advance...
It is possible that your anti-virus software is corrupting the downloaded files or otherwise interfering with downloading files by Firefox.
Try to disable the real-time (live) scanning of files in your anti-virus software temporarily to see if that makes downloading work.
* http://kb.mozillazine.org/Unable_to_save_or_download_files -
In some thread, i had this problem with file download that instead of opening File Save..popup, the contents of file on the server were being rendered statically as HTML. I have figured out the solution to that but now the thing is in every file, there are some \n\r being added in the beginning of the file. Can anybody help. Here's is my code.
<%@ page import="java.io.*"%>
<%
try
response.setContentType("APPLICATION/OCTET-STREAM");
String strProjectInfoPageHeader = "Attachment;Filename=\"" + request.getParameter("txtProjectInfoPageFileName") + "\"";
response.setHeader("Content-Disposition", strProjectInfoPageHeader);
File fileToDownloadProjectInfoPage = new File(request.getParameter("txtProjectInfoPageFilePath"));
FileInputStream fileInputStreamProjectInfoPage = new FileInputStream(fileToDownloadProjectInfoPage);
int varProjectInfoPage;
while ( (varProjectInfoPage=fileInputStreamProjectInfoPage.read()) != -1 )
out.write(varProjectInfoPage);
out.flush();
out.close();
fileInputStreamProjectInfoPage.close();
catch(Exception e)
out.println(e);
%>Thanks and regards
VikramJSPs will invariably have newlines and whitespace in them, even if you don't explicitly put them. Instead of wasting time trying to fix it, just move your code to a servlet and map it to the same path. That's the fastest and most sensible solution. It also follows the convention that JSPs are to be used for display only and servlets for processing.
People on the forum help others voluntarily, it's not their job.
Help them help you.
Learn how to ask questions first: http://www.catb.org/~esr/faqs/smart-questions.html
---------------------------------------------------------------- -
Problem With File Download Dialog Box
Hi all,
I have jsp page that allows a user to export oracle data to excel.
I have these code in my page:
<%@ page contentType="application/vnd.ms-excel" %>
response.setContentType ("application/vnd.ms-excel");
response.setHeader ("Content Disposition",
"filename=\"historicalrate.xls\"");
I run the page and it popups a file download dialog box with Open and Save buttons.
When I click the Save button a Save As window opens with a hr.xsl file name and Microsoft Excel Workbook(*.xls) as save type. It is what I want.
The problem I have is when I click the Open button on the file download dialog box it displays data in excel format on a browser well. Then I click File > save as on browser's tool bar the Save As window pop up with no file name and a default Text(tab delimited)(*.txt).
I need the file name and Microsoft Excel Workbook(*.xls) as default save type.
Any help would be greatly appreciated.
Please help
ThanksI have the same problem with hui_ling.
When user click on "Open", Excel start and open excel file correctly but the file name on excel title bar. 'Cause the file name is in Japanese characters. Any one can help me?
Message was edited by:
TNTVN -
Unwanted File Download box in JSF - Problem while Saving State.
Hi,
I am having a situation wherin there are multiple command links dynamically generated in a dataTable.When I click on any one of the links a file download dialogue pops up to save/open a pdf doc.Irrespective of any operations on the download dialogue, if I click on anyother link (i.e this is the 2nd click on tat page)
then the file download doesnt pop up and instead the page is refreshed.
On the 3rd click , the file download again pops up.
The code in the action method of the command link goes like this
public void showPDF() {
byte[] pdf = // gets the data from another place.
FacesContext faces = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) faces.getExternalContext().getResponse();
response.setContentType("application/pdf");
response.setContentLength(pdf.length);
response.setHeader("Content-disposition", "attachment");
response.setHeader("Cache-Control", "cache, must-revalidate");
response.setHeader("Pragma", "public");
try {
ServletOutputStream output = response.getOutputStream();
output.write(pdf);
} catch (IOException e) {
log.debug("IOException in viewPdf: " + e.toString());
faces.responseComplete();
}To fix the above problem ...I have included the following 2 lines of code just before invoking the responseComplete() method :
StateManager stateManager = (StateManager)
faces.getApplication().getStateManager();
stateManager.saveSerializedView(faces);This solves the above problem but causes another problem for which I need help :
There is a value change listener in my jsp.When I change the value in a drop down list in the same page, the file download dialogue is poping up. which shuld only pop up when am clicking any one of the command links.
I debugged thru the code and found out that after the value change listener action method is finished executing it jumps and executes the above showPDF() method.
Seems its something to do with saving of the client state.
It will be of great help anyone can advise on this.
Thanks
ArchanHi,
I am having a situation wherin there are multiple command links dynamically generated in a dataTable.When I click on any one of the links a file download dialogue pops up to save/open a pdf doc.Irrespective of any operations on the download dialogue, if I click on anyother link (i.e this is the 2nd click on tat page)
then the file download doesnt pop up and instead the page is refreshed.
On the 3rd click , the file download again pops up.
The code in the action method of the command link goes like this
public void showPDF() {
byte[] pdf = // gets the data from another place.
FacesContext faces = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) faces.getExternalContext().getResponse();
response.setContentType("application/pdf");
response.setContentLength(pdf.length);
response.setHeader("Content-disposition", "attachment");
response.setHeader("Cache-Control", "cache, must-revalidate");
response.setHeader("Pragma", "public");
try {
ServletOutputStream output = response.getOutputStream();
output.write(pdf);
} catch (IOException e) {
log.debug("IOException in viewPdf: " + e.toString());
faces.responseComplete();
}To fix the above problem ...I have included the following 2 lines of code just before invoking the responseComplete() method :
StateManager stateManager = (StateManager)
faces.getApplication().getStateManager();
stateManager.saveSerializedView(faces);This solves the above problem but causes another problem for which I need help :
There is a value change listener in my jsp.When I change the value in a drop down list in the same page, the file download dialogue is poping up. which shuld only pop up when am clicking any one of the command links.
I debugged thru the code and found out that after the value change listener action method is finished executing it jumps and executes the above showPDF() method.
Seems its something to do with saving of the client state.
It will be of great help anyone can advise on this.
Thanks
Archan -
types: begin of type_s_data,
record(65000) type c,
end of type_s_data.
data: w_xml_out type string.
data: t_xml_tab type table of type_s_data with header line,
Source code
t_code type table of type_s_data with header line,
After populating t_code table,
convert internal table data into XML document
call transformation id
source code = t_code[]
result xml w_xml_out.
append XML docu to internal table
append w_xml_out to t_xml_tab.
Download to XML file
call function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE =
filename = filename
filetype = 'BIN'
append =
write_field_separator = sep
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
WRITE_LF_AFTER_LAST_LINE = ABAP_TRUE
SHOW_TRANSFER_STATUS = ABAP_TRUE
IMPORTING
FILELENGTH =
tables
data_tab = t_xml_tab
FIELDNAMES =
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
others = 22.
if sy-subrc <> 0.
message e016 with 'Error during file download'(002).
endif.
Problem here is when intrernal table data/size is large, only part of the data is getting displayed in the file and at the bottom of the file showing an error message
The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
End element was missing the character '>'. Error processing resource 'file:///C:/Documents and Settings/sowjanya.suggula/De...
RECORD
^
>RECORD>
</item>
wehn i change data declaration as
data: t_xml_tab type table of string with header line.
when i execute the program, giving me a short dump.please suggest me a soluion for this.
Regards,
SowjanyaHi Sowjanya,
Kindly go through this link below:
It Uploads XML to internal table and vice versa :
Upload XML to internal table and vice versa in SAP 4.6C
Hope it helps
Regrds
Mansi -
Problem with file download option in ALV via ITS. Please help!
Hi Experts,
I have a ALV report which I have web enabled using ITS service. In the ALV there is a delivered functionality for file download. It works fine when the report is run in the SE80. But when I run the ITS service for the report and choose file download option it displays a page saying "this page has been diaplayed due to technical reasons" with title "File properties". In addition it looks for Java runtime in the browser. After all this it opens a popup window for selecting path and file name.
This is not user friendly and many customers have rasied their concerns on it.
My question is that,
Q1: What is the need of this "File properties page"? Why ITS calls this while ABAP editor does not?
Q2: Is there any way we can suppress this so that it directly opens a popup window for selecting path and file name?
Please help me.
Thanks
GopalHello Klaus,
i have also the problem with these intermediate screens!
We have in between installed patch 22 for ITS 6.20 and SP18 at SAP Netweaver 2004!
But they are still not processed invisible for the users.
Are there any additional parameters, which controls this behaviour(~webgui_updown_make_visible is not used!)?
How can i check, if i have really a.ex. the actual ws.jar-file or other related files of the patch?
We are using the standalone ITS with an own (modified) IAC with an own CI-design for the webpages. The intermediate screens are displayed with the "normal" SAPGUI-design because of the parameter ~generatedynpro. Without this it does not work, because the template SAPLSIT_0100 is missing!
Or do you have an example for such a intermediate template with the applet for an upload of a file?
Thanks in advance
Felix -
Problem with File download in ALV via ITS. Please help!
Hi Experts,
I have a ALV report which I have web enabled using ITS service. In the ALV there is a delivered functionality for file download. It works fine when the report is run in the SE80. But when I run the ITS service for the report and choose file download option it displays a page saying "this page has been diaplayed due to technical reasons" with title "File properties". In addition it looks for Java runtime in the browser. After all this it opens a popup window for selecting path and file name.
This is not user friendly and many customers have rasied their concerns on it.
My question is that,
Q1: What is the need of this "File properties page"? Why ITS calls this while ABAP editor does not?
Q2: Is there any way we can suppress this so that it directly opens a popup window for selecting path and file name?
Please help me.
Thanks
GopalHello Klaus,
i have also the problem with these intermediate screens!
We have in between installed patch 22 for ITS 6.20 and SP18 at SAP Netweaver 2004!
But they are still not processed invisible for the users.
Are there any additional parameters, which controls this behaviour(~webgui_updown_make_visible is not used!)?
How can i check, if i have really a.ex. the actual ws.jar-file or other related files of the patch?
We are using the standalone ITS with an own (modified) IAC with an own CI-design for the webpages. The intermediate screens are displayed with the "normal" SAPGUI-design because of the parameter ~generatedynpro. Without this it does not work, because the template SAPLSIT_0100 is missing!
Or do you have an example for such a intermediate template with the applet for an upload of a file?
Thanks in advance
Felix -
PDF Report file download problem
Hi,
I am using ApEx 3.1 and Oracle 10g and XSL-FO
I have a problem in downloading a PDF file:
(1) I have a report query (produced an xml file), report template, and report layout.
After I linked the new PDF report into my application, when I click on the button, the PDF “File Download” popup shows only two buttons (“save” and “cancel”) with a warning message “The file you are downloading cannot be opened by the default program. It is either corrupted or it has an incorrect file type. As a security precaution, it is recommended that you cancel the download”, and the file name shows up as “f.pdf”. I am able to open the saved file (f.pdf) in Adobe Acrobat and it looks fine.
(2) In “Home>Application Builder>Application xxx >Shared Components>Report Queries>Edit Report Query”, when I click on the “Test Report” button, the “File Download” popup shows with all three buttons, (“open”, “save”, “cancel”) --- it shows the correct name of the file, and, no warning message! At this point, the file can be opened with the “open” button”, or, be saved to the disk. The saved file opens with Adobe Acrobat and the contents are identical to that of the file “f.pdf”.
(3) I created another application (within the same workspace) with just one page, linked the PDF report in this application, and clicked on the button, and got the same response as in (2).
It looks like I could try to create a new application by copying page by page from the application quoted in (1), and see if that would solve the problem. It is time consuming, the outcome is uncertain, and also could create some other problems
What could be the cause of this problem? Any alternatives? I would appreciate any help.
Thanks
VasanWe experienced the exact same problem as the OP (including corrupt files named "f.pdf" and the browser dialog box he documented). Don't know if his environment is similar, but here is how we fixed our issue:
Our app uses an Authentication Scheme that includes under "Page Session Management" a "Session Verify Function" called like this: "return timeout_pkg.check_timeout;". This timeout_pkg I think came from code originally posted here, it works well so thanks to the original coder. However it does present a small issue in that it rewrites the mime headers in the server response in one use case. Since it is rewriting the headers to "text/html" even though we are sending back a report where the mime header should be "application/pdf", the client gets confused and the result is the symptoms the OP posted.
So if we change the timeout package and body so the signature is like this: "function check_timeout (p_request IN VARCHAR2 DEFAULT null) return boolean;"
And change the call in the "Session Verify Function" to pass the request as a parameter like: "return timeout_pkg.check_timeout(:REQUEST);"
And change the body of the timeout_pkg.check_timeout function to use the correct mime type when calling a report:
elsif not g_cookie_already_sent then
if (p_request is not null and INSTR(p_request, 'PRINT_REPORT') != 0) then
owa_util.mime_header('application/pdf', FALSE);
else
owa_util.mime_header('text/html', FALSE);
end if;
then we solve our particular problem... I hope this saves somebody else some time, remember this was our specific solution to the exact symptoms documented by the OP, however as a general rule I would say if you are experiencing problems with pdf printing from Apex, watch out for anything your app might be doing with the owa_util pkg in particular and mime headers in the server response in general.
Edited by: cmcneil on Sep 5, 2008 11:45 AM
Edited by: cmcneil on Sep 5, 2008 11:59 AM -
Hi All,
I am working on project where I need to display all the files (on the UI screen)which are in windows folder with a download link.
I used IWDDownload UI element for downloading the file. Its working fine but problem is , when ever I download a file for first time its working fine. Later what ever I download other files, I was able to see only first file download. I guess this is problem with context binding but I am not sure.
I used for loop to iterate all the files in folder and I binded the file name to IWD Download UI element using bindText option.I am creating UI elements dynamically in wdDoModifyView and it will call another method to bind to context.(As SAP Suggested not to modify any context elements in wdDoModifyView method).
Please help me in this regard.
RameshRamesh,
You need N dynamic binary attributes or IWDResource (in newer versions), one per file. Create them either in wdDoInit of view or in some suitable action handler.
Then you have to populate IWDResource or set bytes of binary attributes. Check corresponding WD tutorials how to do this.
In wdDoModifyView create IWDFileDownload control per every attribute and bind either "data" property (to binary attribute) or "resource".
Valery Silaev
Maybe you are looking for
-
At what percentage should I to charge my macbook pro and prolong the life of my battery?
I want to prolong the life of my laptop battery. I just got a new macbook pro and want to know the proper way to charge the battery.
-
Problems with iPhoto and Aperture after installing Mavericks
I use iphoto 11, version 9.5 (902.7) and Aperture 3.5. both are dodgy since installing Mavericks - freezing, not allowing access while wheel spins, showing "Processing". I've re-installed both aperture and iphoto from the Apps store. No difference.
-
I have tried to update my iphone4 time after time and after waiting an hour it says error and my time has ran out ?? How do you update it?
-
How do I get my printer to do wireless printing? What drivers do I need to install? Do I need to setup a network? How do I get the printer to be set on "Direct?" How do I get the printer to have the same SSID as my router? Presently, the blue wifi
-
Can you restart/store safari on mac with the new os x update?
can you restart/store safari on mac with the new os x update?