Eror downloading a XLS file on the portal hosted struts/j2EE application

guys,
1st of all please bare with for writing such a huge mail but to explain the scenario i had to do this.
i am trying to download a XLS file from the web application (struts/J2EE) hosted on the portlet.
on my portlet i have few text boxes and a button.
onlcik of the buton there are few validation javascripts and if the valdatin is thrugh then the form is submitted.
there are 2 ways i can submit the form to the struts action class.
both approaches have some problem or the other.
Apporach 1
var postUrl = document.getElementById('getReportURL_$$PORTLET_ID$$').innerHTML;
var post = new PTHTTPPOSTRequest(postUrl, form, handleInlinePostResponse_$$PORTLET_ID$$);
post.invoke();
this is like a AJAX request post where the response comes back in the function handleInlinePostResponse_$$PORTLET_ID$$ which can be then handled.
Problems
1. as from action class i am trying to send a XLS file, i am writing the byte stream of the XLS file on the output stream of the response. when the response reaches the function handleInlinePostResponse_$$PORTLET_ID$$ on portlet jsp it gives me an javascript exception 'End of file reached in invalid state for current encoding' but while sending the response i am encoding the byte stream.
the code snippet from the action class is as below
response.reset();
response.resetBuffer();     
response.setHeader("Content-disposition", "attachment; filename=" + reportData.getFilename());
response.setCharacterEncoding("UTF-8");
response.setContentType("application/vnd.ms-excel");
response.getOutputStream().write(reportData.getContent()); //byte[] form of the XLS file
return null; //as we write on the response out stream the response is already commited hence the return null has no significance.
2. in case of the any exception on server side this approach is helpful as the error content jsp is rendered in to the portlet from where the action was fired.
Approach 2
form.action = "<pt:url xmlns:pt='http://www.plumtree.com/xmlschemas/ptui/' pt:href='downloadCommercialXLSReport.do'/>" ;
form.submit();
This approach is normal for submitting any struts from bean to the struts action class (i know this is not a aprropriate way to submit d form through portlet as it submits whole page inclusding all the portlet data)
Problems
1. here in case of the sucess the XLS file is returned to the browser which openes a browser specific dialogue box having 'Save' 'Open' and 'Cancel' buttons to save/open the XLS file. (please note no javascript exception occurs here as approach one as the byte streeam content is returned to the browser directly and not to any post response handler function as handleInlinePostResponse_$$PORTLET_ID$$)
2. But here the problem is in case of any sever side exception the error jsp is rendered on whole browser page and not in portlet which is kinda goofy.
so now i am in a catch 22 scenario each approach has 1 problem either in success or in failure flow.
can sombody suggest me a way out from this as i desperately need to download a XLS file.
lemme kno if anybody has done a similar download stuf through portal server.
regards,
Sush

i have done this before although it was in .net. try the first approach but first pop to a new window....the xls response has to be the only response to the browser or else the browser will take the other bytes returned as garbage and call the stream corrupt. let me know how this goes for you.
if you still have problems i can post the code that worked for me. it is in c# but looks very similar.

Similar Messages

  • Hi i am trying to download a .xls file from server but i cant

    I am using Tomcat 5.0, Where i am trying to download a .xls file.. which was uploaded by me.. when i try to download the file using line.. the content of the jsp file is there in the .xls file, i cant get the original .xls file
    here my code.. i am request this page by a button click...
    browser ask me to save download.jsp file....
    how to download a .xls file from the server... the file was uploaded by me to a folder temp
    <%@ page
    contentType="application/vnd.msexcel; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"
    %>
    <jsp:include page="http://localhost:9999/temp/B.xls"/>

    Help me please, I have this:
    File ficheroXLS = new File(strPathXLS);
    FacesContext ctx = FacesContext.getCurrentInstance();
    if (!ctx.getResponseComplete()) {
    String fileName = ficheroXLS.getName();
    String contentType = "application/vnd.msexcel";
    HttpServletResponse response = (HttpServletResponse) ctx.getExternalContext().getResponse();
    response.setContentType(contentType);
    response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\"");
    ServletOutputStream out = response.getOutputStream();
    out.write({color:#ff0000}ficheroXLS.toString().getBytes(){color});
    out.flush();
    out.close();
    ctx.responseComplete();
    My
    problem is marked with red color, I have a file. XLS and I want to
    download it, but to put what this red just showed me the PATH ...
    How can I do to make the contents of this file?
    What type of object must be the xlsReport?
    thanks greetings

  • Edit a mounted file on the portal

    Hello,
    I have mounted a directory from our file server on our portal server. I implemented this directory in our KM file structure with a file system repository. Now in this directory is an Microsoft Excel file. The mount is read-write and I have write access to the document on the file server and in KM structure. But how can I edit this file in the portal? I can access this file with KM Document iView but I cannot change the content of this file and save it. Can anyone explain me that?
    Best Regards
    Philipp

    Hi,
    the KM document iView is for displaying content. To be able to edit it, you need access to the conent menu of the file. Use the KM folder iView to access the folder where the xls is stored. From there, you can also edit files.
    You can also use the portal drive to access the KM folder with WebDAV. This way, the KM folders and files will apear as explorer folders and files.
    br,
    Tobias

  • Deploying an existing WAR file into the Portal

    I have downloaded the Enterprise Portal and the SAP Netweaver Developer Studio (NDS) and have succeeded in creating a couple of projects of the ‘Hello World’ variety and deployed them on the Portal!  So far, so good.
    The problem I have is that need to deploy on the Portal an existing JSP/Struts application of ours which is available as a Web Archive (WAR) file.
    The problem is that I cannot find a way of deploying an existing WAR file on the Portal – either via a Project or otherwise.  I have found an entry in the Help files with the NDS which sounds promising, as it is entitled ‘Import a .WAR File into a new project’.  However, the menu entry it says you should use (File &#8209;> Import &#8209;> MDK: Import a web archive (.WAR) into a new project) this last entry does not exist on my installation of NDS.
    Any ideas or suggestions?

    Hi Mustafa (and All) - thanks you very much for your answers, which has enabled me to make good progress.
    I have created a project in the Deploy Tool, imported a simple WAR file into it, loaded to project and depployed it on my instance of the Portal - or at least I have deployed it as far as the Deploy Tool is concerned. 
    However, when I try to find it in the Portal in order to assign it to an iView in the Portal content, I can't find any evidence of its existence!!
    As another 'tack' in the NDS I have created an 'Enterprise Application Project', into which I appear to have imported the WAR file - but I cant package this as a PAR file, which is what I seem to need to do to get it into an iView on the Portal.  To create a PAR package I seem to need to create a 'Portal Application Project' - but I can't find a way of getting the WAR file into that!!
    Any further advice would be greatefully received.
    Thanks for your help to date and thanks in advance for any more you may be able to give.
    Regards,
    Dave

  • Not able to view the uploaded PAR file in the portal archive selection.

    Dear All,
    I have modified com.sap.portal.runtime.logon.par and have renamed it to some other name.
    Now I have uploaded the par file.
    The problem is that when choose new from PAR option (to create iview from a par file),I am not able to see the par file in the Portal Archive selection.
    I also want to know that if I am able to call the par file in the iview, can I use this iview to have a portal login.
    Our requirement is that we want to give login page for the portal in the portal home page.The portal home page will be for the anonymous users.
    Kindly try to guide me

    Hi Nitin,
    Check ur Portalapp.xml file. If u have the following code in that just <b>remove</b> them
    <property name="com.sap.portal.pcm.Category" value="platform">
    <property name="inheritance" value="final"/>
    Deploy it again.now u can see that par in ur portal.Refer this thread also
    PAR File not seen
    Regards,
    Tamil K

  • How to download a pdf file from the server from an strut application?

    Hi,
    I wan to download a pdf file from the server side to local system. Please help me how i use the down load option.

    Read up on the Struts download action [1].
    And next time, please post in the relevant forum, one of the web-tier ones [2].
    [1] http://wiki.apache.org/struts/StrutsFileDownload
    [2] http://forum.java.sun.com/category.jspa?categoryID=20
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    ----------------------------------------------------------------

  • Unable to Deploy Par  File in the Portal

    Hi Experts,
    When i'm trying to deploy the par file to the portal after Configuring the server settings it's giving me an error.
    "Operation Failed: Please make sure the server 'DEV' (hostname:port) is running or check the log (sap-plugin.log) for more detail "
    And please guide me where i can find the log file sap-pluginng to check the logs as i'm new to the NWDS i'm not able to locate the file.
    Regards,
    Nilesh

    Dear Nilesh,
    Check that you have set the followings configurations:
    - Windows -> Preferences -> SAP J2EE Engine:
         Message Server host: Portal Server
         Message Server port: ms of portal 390x (not 50x00) you cand find your message server port in http://server:port/index.html -> System Information (Message server table)
    - Windows -> Preferencies -> Sap Enterprise Portal (there you need to put the 50x00 port).
    Try with this a comment, regards.

  • Adding files to the portal

    Hi
    I have an HTML form which has an <input> of type "file." I want to enter a file into the portal, into a specific folder within a specific content area. Supposedly, all I need to do is use the wwsbr_api.add_item function. I've created a PL/SQL procedure which I call from my HTML that what it does is get the parameters from the HTML form (the file name), and then apply the add_item function.
    (I do know the folder's and the content area's id).
    It's not working. I'm getting an ORA-29532 Error. (some Java security exception)
    So, how do I enter a file directly into the Portal?
    (A code example would be great!!!)
    Thanks,
    Dan
    p.s
    I've seen in some example where they use a wwv_.....saveitem function (cant remember the package name -- I could look it up if anybody is interested). This function is not documented anywhere, and so I'm afraid to use it because I dont understand all the parameters, and who knows what changed they'll do to it in the next version and I wont be able to use it anymore....

    Dan,
    You have two options.
    If you want to upload the document via a browser - then use the add_item_post_upload function (vs the add_item function).
    This function assumes that the document is already uploaded and that the p_file_name being passed is the actual document 'NAME' returned when the document is uploaded.
    The other option is to use the add_item procedure and put the document somewhere on the same machine as the database
    -- then the value for p_file_filename is expected to be "The full directory and filename for the file to be uploaded for this file item. The file path must be visible from the
    database machine." If this method is used then the document will be uploaded from the directory into the database as part of the add_item function.
    Hope this helps.
    Mohana

  • How to send a file through the portal

    Hello,
    I have a problem in sending the file. I have selected a file kris.ppt and from context menu, I have selected sent to option and I have sent a file. I got a copy of that to my lotus notes but in that I had a format as kris.ppt.html. I cannot open the file. I can open the file when the portal is running. But I want to open the file when the portal is closed. Can anyone tell me the solution.
    cheers
    kris

    Hello Shankar,
    I tried that option also by default I'm getting 2 options.
    One is the kris.ppt.html and other is the kris.ppt. I cannot open the first one rather I could open the second. I can open the 1st one if the portal is opened. Can you suggest anything regarding that one.
    cheers
    kris

  • Using utl_http to download a binary file to the server disk

    Hi,
    I need to download a binary file from the web into the hard disk of the server.
    I am using utl_http to do that. My program works on URLs that have text, but not on binary files. Does anyone have an idea how to do that?
    Thanks
    Rani
    Here is the program I am using:
    DECLARE
    req utl_http.req;
    resp utl_http.resp;
    value VARCHAR2(32767);
    fname utl_file.file_type;
    BEGIN
    utl_http.set_proxy('wwwproxy.myorg.com:8080');
    req := utl_http.begin_request('http://www.somelocation.com/abc.zip');
    resp := utl_http.get_response(req);
    fname := utl_file.fopen('DBTEMP','testfile.zip','w');
    LOOP
    utl_http.read_line(resp, value, TRUE);
    utl_file.put_line(fname,value);
    END LOOP;
    utl_http.end_response(resp);
    utl_file.fclose(fname);
    EXCEPTION
    WHEN utl_http.end_of_body THEN
    utl_http.end_response(resp);
    utl_file.fclose(fname);
    END;

    Try to use UTL_HTTP.READ_RAW.

  • Hi. I have Lightroom 4 installed. I cannot download my CR2 files from the Canon 5D Mark III camera. I have downloaded Lightroom 5 thinking it was an update but it appears I have to pay for the program. Any ideas how I can get lightroom 4 to accept my CR2

    I have Lightroom 4 installed. I cannot download my CR2 files from the Canon 5D Mark III camera. I have downloaded Lightroom 5 thinking it was an update but it appears I have to pay for the program. Any ideas how I can get lightroom 4 to accept my CR2 files ?

    The Canon 5D Mk 111 was supported from LR 4.1, see the link below. Just update LR to the latest version. See link below
    Camera Raw plug-in | Supported cameras
    Adobe - Lightroom : For Windows
    Adobe - Lightroom : For Macintosh

  • Unable to delete file on the remote host

    Hi,
    I tried to delete a file on the remote host using File.delete method as well as using Runtime.getRuntime.exec("del filename")
    But both of them failed to work. First one returned false, but the second one is throwing IOException always.
    I am trying this through a java application in Windows NT environment. I am using jdk1.3. How can i solve this problem?.
    IOException occured at DataLoadFromTxtToOra exeBatchForTWS: CreateProcess: del \\ERSWEB\DTemp\ERS\HEB_428\DATAFILES\ERSWEB\DLCOMMA.txt error=2
    Regards,
    Babu

    you should be able to do that if you have rights on the file, try the following code and substitute the computer/share names:
                   File aFile = new File("\\\\COMPUTER\\share\\filename.ext");
                   System.out.println("Read: " + aFile.canRead());
                   System.out.println("Write: " + aFile.canWrite());
                   System.out.println("Exists: " + aFile.exists());
                   System.out.println("File: " + aFile.isFile());
                   aFile.delete();Mind the slashes: a single backslash is causing a escape character: \n for example is a (unix) return. A double \\ defeats it and results in a single \ in the filename
    If everything returns true I think the file will be deleted. If isFile() returns false you've got the path/filename wrong.

  • I want to open a domain.site2 file outside the default folder (User/Library/Application Support/iWeb) with iWeb11, but iWeb only opens the domain file in the default folder. If I delete the default domain file, iWeb wants to create a new site. Help please

    I want to open a domain.site2 file outside the default folder (User/Library/Application Support/iWeb) with iWeb11, but iWeb only opens the domain file in the default folder. If I delete the default domain file, iWeb wants to create a new site. Does anyone have the same problem or know how to fix it?

    In Lion the Finder folder is now invisible.  To make it permanetely visible enter the following in the Terminal applicaiton window: chflags nohidden ~/Library and hit the Enter button - 10.7: Un-hide the User Library folder.
    For opening your domain file in Lion for the first time or to switch between multiple domain files  Cyclosaurus has provided us with the following script that you can make into an Applescript application with Script Editor. Open Script Editor, copy and paste the script below into Script Editor's window and save as an applicaiton.
    Just launch the applicaiton, find and select the domain file you want to open and it will open with iWeb. It modifies the iWeb preference file each time it's launched so one can switch between domain files.
    do shell script "/usr/bin/defaults write com.apple.iWeb iWebDefaultsDocumentPath -boolean no"delay 1
    tell application "iWeb" to activate
    OT

  • TMS cannot open the file on the different host

    Hi!
    I have very simple scenario: 2 Systems (DEV and PRD) on the different hosts which should be configured in the TMS.
    I have done the following:
    - I have changed the DIR_TRANS-parameter on the PRD-host and gave him the value of the DEV in the instance-profile. Unfottunately the error appiers "this folder does not exist"
    If I do the transport group check I see the red points. This means I cannot open the file on the different host (e.g. from DEV on the PRD and opposite).
    Should I set users manually or share the folder or something like this to give access for the TMS?
    Thank you!
    regardss

    Thank you Eugene, I could open the document by changing it's name
    Greetings
    Pall Jokull
    Reykjavik, Iceland
    2009/4/11 Eugene Tyson <[email protected]>
    rename the file so that there are not two "dots" in it.
    >
    you have ".2008.indd"
    >

  • How to install new font file in the device when deploying J2ME application?

    i would like to know how to install the new font file in the device when deploying J2ME application, side-by-side.
    Is that possible to seamlessly install the new font file with the application .jar package.
    thnx.

    No, there is no way of installing new fonts.

Maybe you are looking for

  • Netmask Changes in Solaris 10

    Hi Team, We tried to change the netmask and broadcast address in solaris 10 by below steps ifconfig ipge0 down ifconfig ipge0 <ipaddress> netmask <subnet mask> broadcast <address ifconfig ipge0 up But interface is not up. The command (ifconfig ipge0

  • IPod classic click wheel issues

    Hi, I've got a 160gb iPod classic. About a year old. Increasingly, I've been having click wheel issues wheel the click wheel is unresponsive. Is this a common occurrence? The iPod plays fine. Is thee anything I can do or should I take it to an apple

  • My iPad screen is unreadable!

    My iPad screen is unreadable. This happened 2 days after I upgraded to IOS 6. There is a blue line around the perimeter of the screen. I can turn it on and kind of see the apps but it is unreadable due to the vertical lines that blur them out. I have

  • Adding a page border

    I'm hoping that this is simple: How do I add a border around an entire page?

  • Date formatting with java and axis

    Hi, My wsdl file has date field which uses xsd:dateTime data type. In my web service implementation java class I am passing value to this variable using Calendar.getInstance(). I am using Axis framework. When I check my soap output using TCP monitor