Excpetion after link is clicked for file download on same page

I have implemented a module in JSF where the page displays a datatable and one the columns is a command link which when clicked opens up a dialog box to save a CLOB from the DB as a csv on the local desktop.
All this is working fine.
The problem is that once the user clicks on one link in the datatable and then the user again clicks on any other link on the page or tries to use the Logout link the page is directed to the welcome page.
The problem is happening because of the <h:commandLink> causes the page to submit and thereafter any click on the page causes the page to go to the homepage.
// Constants ----------------------------------------------------------------------------------
  private static final int DEFAULT_BUFFER_SIZE = 102400; // 100 KB.
  // Actions ------------------------------------------------------------------------------------
  public void downloadcsv()
    throws IOException, ServiceLocatorException, ReportServiceException
    ReportSummary selectedReportId =
      (ReportSummary) summaryBindingReport.getRowData();
    ReportContent reportObj =
      getReportService().getReportContent(selectedReportId.getReportId());
    // Prepare.
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    HttpServletResponse response =
      (HttpServletResponse) externalContext.getResponse();
    BufferedInputStream input = null;
    BufferedOutputStream output = null;
    try
      // Init servlet response.
      response.reset();
      response.setContentType("plain/text");
      response.setHeader("Content-disposition",
                         "inline; filename=\"" + selectedReportId.getReportName() +
      output =
          new BufferedOutputStream(response.getOutputStream(), DEFAULT_BUFFER_SIZE);
      char[] strReportContent = reportObj.getReportText();
      Utility.logMessage(Constants.SEVERITY_INFO,
                         "**** Report Content ****" +
                         String.valueOf(strReportContent), this);
      // Write the Report Content as Comma Separated values
      output.write(String.valueOf(strReportContent).getBytes(), 0,
                   strReportContent.length);
      // Finalize task.
      output.flush();
    finally
      // Close streams.
      close(output);
      close(input);
//    ReportCriteria reportSearchCriteria = new ReportCriteria();
//    reportSearchCriteria.setSubSystemCode("AC");
//    setManagedBeanValue("reportList",
//                          getReportService().searchByCriteria(reportSearchCriteria));
    // Inform JSF that it doesn't need to handle response.
    // This is very important, otherwise you will get the following exception in the logs:
    // java.lang.IllegalStateException: Cannot forward after response has been committed.
        facesContext.getRenderResponse();
    facesContext.responseComplete();
//    return "reportSummary";
  private static void close(Closeable resource)
    if (resource != null)
      try
        resource.close();
      catch (IOException e)
        e.printStackTrace();
  public void setSummaryBindingReport(HtmlDataTable summaryBinding)
    this.summaryBindingReport = summaryBinding;
  public HtmlDataTable getSummaryBindingReport()
    return summaryBindingReport;
  }

There are two ways to do this.
1. you create a modern day css-file with the classes for the
links you want colored, which is preferred in XHTML-environments.
a. go to Edit, Administer websites, choose your website
b. Users and roles is selected, pick you role (administrator
I presume) and choose Edit Role-settings
c. pick Styles and Fonts
d. form the drop-down list behind Style-support, choose
Document level css
e. pick: Show only CSS styles included in this CSS file
(pick the file you created)
f. use the classes in editing mode for your secific links
g. done
2. you change the role-settings and do it the old-fashioned
way make it possible to use font-tags and use HTML for the source
code
a. go to Edit, Administer websites, choose your website
b. Users and roles is selected, pick you role (administrator
I presume) and choose Edit Role-settings
c. pick Styles and Fonts
d. form the drop-down list behind Style-support, choose HTML
tags (<font etc....
e. done
Have fun editing
Hayo

Similar Messages

  • I can't play a video from apple website..."missing plug-in" message appears but no link to click for download...

    I can't play a video from apple website..."missing plug-in" message appears but no link to click for download...help please...thanks!

    I disabled my divx and it worked well already...

  • Any way to set up iWeb pages for file download / sharing?

    I have been using .Mac Homepage to set up several web pages to share audio files with my clients. I have been able to set up a different web page for each client, each with their own password, with files there for them to download.
    Is there a way to duplicate this using iWeb now that .mac homepage sites are going away? I don't want the audio to stream, I just want to make the files available for downloading, and don't see any page templates in iWeb '08 for file downloading.
    I know that I can use mobileme's new file sharing feature to email links to individual files, but this doesn't work as well as having all the files downloadable on one or more web pages.

    If you have all of the sites in one domain file you should be able to upload only the changed pages but it's been a while since I used 08 so don't remember. You can move each site into its own domain file so that only that site is edited and published. And if you're publishing directly to mobile me only the edited files should be uploaded.
    I use iWebSites to manage over 75 individual sites.. It lets me create multiple sites and multiple domain files.
    If you have multiple sites in one domain file here's the workflow I used to split them into individual site files with iWebSites. Be sure to make a backup copy of your original Domain.sites files before starting the splitting process and move it to another location on your HD until you're satisfied the separation process is completed and what you want.
    This lets me edit several sites and only republish the one I want. Make sure you're running the lastest version of iWeb, 2.0.4 I believe.
    An example of files set up for immediate download is Toad's Cellar. Each linked is linked to a zipped file which downloads when clicked on. The site could be password protected if so desired.
    OT

  • Java WebDynpro's and IE security settings for file download

    We have a EP 7.0 SP13 environment on which we have deployed a number of own developed java webdynpro's. In some of these webdynpro's we provide the file download functionality. The portal and webdynpro's are used by both internal personnel and external customers.
    On the other hand the default Internet security settings for Internet Explorer, disable "Automatic prompting for file downloads".
    When a user, with these default security settings active, tries to use our webdynpro's file download functionality, the screen seems to refreshes but no file download starts. When (s)he retries, the session runs for some minutes and gives following error message:
    "com.sap.tc.webdynpro.services.session.LockException: Thread SAPEngine_Application_Thread[impl:3]_20 failed to acquire exclusive lock on client session ClientSession".
    This behavior is explained in SAPNote 1234847. Webdynpro provides a single-thread module, meaning a user session is blocked for the during of the request. And because the previous file download isn't yet completed the new try can't start.
    Issue now, although the users IE settings allow file downloads and don't block pop up's, he can't download the file and even isn't made aware of the cause of the failure.
    How can we avoid this issue, without having to communicate the
    application requires specific browser settings?

    Welcome to the Apple Support Communities
    See > http://support.apple.com/kb/HT5290
    You can install the program using different ways:
    1. Right-click the application installer and choose Open.
    2. Go to System Preferences > Security and Privacy and select Anywhere in Allow applications downloaded from

  • Drop-down Menu to Open URL for File Download

    I am using Adobe Captivate 5.5 and was wondering if it is possible to create a drop-down menu that can be used to open different URLs for file downloads, kind of like the Attachments button Presenter has. Captivate seems to have a dropdown widget available but I can't tell if this would work for this purpose.

    Hi Theo
    You can use any composition to create a menu with setting for show target on rollover and then link targets to specific pages.
    Adobe Muse CC 7.0 Tutorial | Beautiful Graphic Navigation - YouTube
    Thanks,
    Sanjit

  • JSF error message: Automatic prompting for file download

    This is a weird problem. I have a JSF application wherin I popup a new window on a submit button.
    The window opens a test.jsf page that redirects the output to a servlet1.
    Servlet then based on some parameters does a sendRedirectI() to different servlets out of context.
    Now the issue is that when the output is redirected to out of context servlet, that returns a file download.
    If in IE browser, if one does not do a setting of "Automatic prompting for file download", this window that I had opened on submit buttton vanishes in a jiffy. If the IE setting is done, it shows the file download correctly.
    I would want to show the user some kind of message by which he/she understands that this IE setting has to be done.
    I have tried several ways:
    1. Javascript: window.onbeforeunload on the test.jsf so that when the window unloads i can show some message. But since test.jsf forwards to servlet1, the html page generated does not show my script.
    2. I also tried checking if some windows registry can help me understand the setting.
    3. I tried writing in response object the javascript and then redirecting it to servlet out of context. But I guess sendRedirect() does a new request, so this did not help.
    Can anyone help? I am not sure if I am able to explain my problem correctly.
    Yani

    Here is the result.I used your code and it worked fine with IE setting Enabled. But when I tried to access the download servlet after opening a new window, it doesnt download the file.

  • Problems with signed Applet for File Download under JRE 1.4 (works with 1.3

    Dear all,
    i encountered a very strange behaviour with JRE 1.4x. A signed applet used for file download worked on all platforms (Windows NT, 2000 and XP wth/wthout SP...) until I installed JRE 1.4.x (1.4.1 or 1.4.2)
    I get an EOFException when downloading binary files (for ASCII it works fine) when trying to readByte() from a DataInputStream. But not immideately, but after x bytes in the while-loop. Security is fine (I know there have been changes to that in jre 1.4, the applet itself can be started an runs with ASCII files for transfer)
    Does anyone know, what has changed in jre1.4.
    As I said, it works fine under jre 1.3.x
    The relevant code is below: byte bt = dis.readByte(); causes the error
    try{
    // Get URL from Server
    URL uFile = new URL(sFilename);
    sThisURLFile = uFile.getFile();
    Integer inte = new Integer(i);
    //open input stream for the file on server
    DataInputStream dis = new DataInputStream(new BufferedInputStream
    (uFile.openConnection().getInputStream()));
    //open output stream for the file on local drive
    String sFilenameOnly = sThisURLFile.substring(sThisURLFile.lastIndexOf('/')+1);
    int iDotPos = sFilenameOnly.lastIndexOf(".");
    String sExt;
    if (iDotPos > 0) {
    sExt= sFilenameOnly.substring(iDotPos);
    } else {
    sExt = "";
    File fileOut = new File(sDownloadDir + sThisURLFile.substring(sThisURLFile.lastIndexOf('/')+1) );
    DataOutputStream dos = new DataOutputStream(new
    BufferedOutputStream(new FileOutputStream(fileOut)));
    //read one byte from input stream, and write that byte to output stream
    long nByte = 0;
    int iCnt = 0;
    iFilesizeDone ++;
    while (nByte < iFilesize){
    String sErrPs = new String();
    try{
    sErrPs = "00";
    byte bt = dis.readByte();
    sErrPs = "01";
    dos.writeByte(bt);
    } catch (EOFException ee)
    System.err.println("internal EOFException: " + ee.getMessage());
    System.out.println("Error Filesize is " nByte " of " iFilesize "---" + sErrPs);
    break;
    nByte++;
    iFilesizeDone ++;
    iCnt ++;
    if(iCnt >= 10240) {
    ShowProgress(nByte, iFilesize, iFilesizeDone, iFilesizeTotal); // repaint does not work during init-procedure
    iCnt = 0;
    line = "Progress: Total: " + ((iFilesizeDone*100)/iFilesizeTotal) + " perc, " + iFilesizeTotal/1024 +" kbytes" ;
    labLine.setText(line);
    //dos.flush(); // improves Client performance (Agent-Call!)
    dis.close();
    dos.close();
    }// End try
    catch (EOFException ee)
    System.err.println("EOFException: " + ee.getMessage()e);
    catch (SecurityException se)
    System.err.println("SecurityException: " + se.getMessage());
    catch (IOException ioe)
    System.err.println("IOException: " + ioe.getMessage());

    perhaps they've changed something with the file blocking.
    btw, you should try to use something like this
    DataInputStream dis = new DataInputStream(is);
    byte[] buffer=new byte[8192];
    int numBytesRead;
    while ( dis.available()>0 ) {
         numBytesRead = dis.read(buffer);
    }               

  • Automatic prompting for file download

    I am using a File Download Servlet. Theres a setting in IE under Securiy Settings --> Downloads--->Automatic Prompting for File Downloads.If I have this disabled, I am able to download the file.If its enabled, I am unable to download the file successfully. Anyone have faced this problem before?

    Here is the result.I used your code and it worked fine with IE setting Enabled. But when I tried to access the download servlet after opening a new window, it doesnt download the file.

  • Adding a new layout for DME for file download

    Hi All,
    How do i add a new layout for file download in DME?
    Thanks
    William Wilstroth

    This problem is solved.
    Need to enhanced the T042O table.

  • Peformance Turning for File Download / Upload with Enabled SharePoint Audit

    Greetings all, may I ask your help for Peformance Issues?
    Background:
    I tried to create a ASP.NET Web Page to download/upload/list SharePoint file and deployed to IIS website in same application server (will NOT use web part as some users are NOT allowed to direct access confidential workspace)
    Besides, for Audit Log record purpose, the page will impersonate (without password) the logged in user:
    SPUserToken userToken = web.AllUsers[user].UserToken;
    SPSite s = new SPSite(siteStr, userToken);
    For File Listing, the web service can provide fast response, and we are using service A/C for connection (as no auting for listing, but require audit for file download upload)
    Several implemeation options tested for File Downloiad / Upload, but issues occured and finding listed below:
    Issues
    1) SharePoint Object Model
    When I open Site (using new SPSite), it's too slow to respond. (under 1s for all operations, but require 10~50s for open SPSIte. e.g.
    using(SPSite s = new SPSite(siteStr) //50s
    How can I download/upload file without open SPSite object (using SharePoint object model, but user token should be kept to allow SHarePoint identifiy user actions. e.g. Updated by Tom, NOT system administrator)?
    2) SharePoint default web service
    For file download, I tried to use SharePoint Web Service for download file, it's quick but how can SharePoint record the audit log to downloaded user, and not service A/C? ( e.g. View by Tom, NOT system administrator)
    With Windows SSO solution, please note system should NOT prompt to ask user password for use impersonation
    3) HTTP Request API (for file download)
    As mentioned in point 2, if the system cannot get password from user, SharePoint also recorded service A/C in audit log... ><
    Thank you for your kine attention.
    .NET Beginner 3.5

    Thank you for prompt response, please find my reply with Underline:
    Hi,
    Maybe I'm not quite clear about the architecture you have now.
    Is your asp.net application deployed in separate IIS site but in the same physical server as SharePoint?
    Yes
    "we are using service A/C for connection", can you please explain the 'A/C'?
    Domain User, Local Admin and also SharePoint Service Admin A/C
    Opening SPSite is relatively slower but shouldn't take 50 sec. However it depends on your server hardware configuration. You should meet the minimum hardware requirements for SharePoint.
    Assigned double resources based on minimum hardware requirements.
    For details, 50s is the load test result. But for other SharePoint operation, it takes around/under 3s reponse time.
    Are you using SharePoint Audit log? Exactly If so then why don't you just put the hyperlink to the documents in your asp.net page. User maybe have to login once in SharePoint site but
    it depends on your security architecture. For example if both of your sites in local intranet and you are using windows integrated authentication, SSO will work automatically  User is NOT allowed
    to access SharePoint site/server (not implemented for sepreate server yet, as performance issues occured for
    separate site in same server)  directly from Internet, the
    middle server with web interface created for user request.
    Whatever I understands gives me the feeling that you download the file using HTTPWebRequest C# class. However regarding security it depends on how authentication is setup in asp.net web site and in sharepoint. If both site uses windows integrated security
    and they are in the same server, you can use the following code snippet:
    using (WebClient webClient = new WebClient())
    webClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
    webClient.DownloadFile("file ur in sharepoint", "download directory");
    Thanks, will try and reply later
    But still, as I've mentioned, not quite clear about the whole architecture.
    A) Request Handling
    1) User use browser to request file listing and/or download file (hereafter called: File Download Request) from custom ASP.NET page (Let's say In Server 1, IIS 1)
    2) ASP.NET page  or File Handler ashx (Server 1, IIS 1) call custom web service, SharePoint deault/OOTB web service or using SharePoint Object Model to access SharePoint Document Library (in Server 1,
    IIS 2)
    3) Both SharePoint and IIS Web Site
    (Server 1, IIS 1 & IIS2) using the same service A/C
    4) The web service , File Handler return file obeject to IIS1
    5) IIS 1 reply File Download Request to user
    B) Application Architecture (In testing environment)
    1) no load balancing
    2) 1 DB server (Server 2)
    3) 1 Application Server (with IIS 1 - ASP.NET, IIS 2, SharePoint Web Site with default SharePoint Web Service, IIS 3 SharePoint Admin Site & IIS 4 Custom SharePoint Web Service)
    4) Sepreate AD Server (Server 3)
    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com
    .NET Beginner 3.5

  • Secondly, i used migration assistant to move everything from old laptop to new. when i used pages on new machine, 10.8.5 operating system, there is no click for file save as in the menu, only flle save. why?

    secondly, i used migration assistant to move everything from old laptop to new. when i used pages on new machine, 10.8.5 operating system, there is no click for file save as in the menu, only flle save. why?

    Hold down Option key while clicking on menu bar and Save as will appear.

  • How to create links to different files on the same page?

    Good day to all again,
    can someone please guide me through creating several links to different files on the same page. In other words, I am creating a photo page where my links are called Gallery 1, Gallery 2, etc... I would like to create links so when the User clicks on Gallery 1, they see Gallery 1 slide show in the frame; when the user then clicks Gallery 2, then they see Gallery 2 slide show in the window.
    My slide show files are done and I am using GoLive CS2. I have no knowledge of JavaScript or ActionScript/Flash.
    Any suggestions are highly appreciated.
    Thank you
    Alek

    Hi Diana,
    I'm a professional photographer and in the process of getting
    my finished site published. I used Coffeecup Photo Gallery. You can
    create multiple albums on the same page. Do a Google search for the
    address. It's easy, inexpensive, and it works. I tried to do this
    with the Photo Gallery in DW and FireWorks--but couldn't get it
    right. CC uses Flash and Javascript.
    Good Luck

  • Does anyone know where the iWeb data files are located or what they are called?  I can't find them.  I looked in Finder for files named the same as my website, but found nothing.  Any help would be appreciated.

    Does anyone know where the iWeb data files are located or what they are called?  I can't find them.  I looked in Finder for files named the same as my website, but found nothing.  Any help would be appreciated.

    If you erased or replaced your hard drive since iWeb was cancelled, then they are gone. Otherwise, if you have maintained backups then check those.
    Usually such files are in the /Home/Library/ folder or a sub-folder.
    Exposing the /Home/Library/ Folder
    Pick one of the following methods:
    A. This method will make the folder visible permanently. Open the Terminal application in your Utilities folder and paste the following at the command prompt:
    chflags nohidden ~/Library
    Press RETURN.
    B. Click on the Desktop, press the OPTION (⌥) button, select Library from the Finder's Go menu.
    C. Select Go To Folder from the Finder's Go menu. Paste the following in the path field:
    ~/Library
    Press the Go button.

  • Is database link only 'valid' for instances in the same server?

    Background: We have 5 servers and installed Oracle 7.3 and 8.
    Problem: I managed to create database link to other instance in same server; but not to other server. Error message received was :
    ORA-02019: connection description for remote database not found
    : TNS server name not found
    BUT: I managed it with 'copy from ' command in SQL*plus.
    Question: Is database link only 'valid' for instances in the same server?
    Thanks! ;o)

    user10127912 wrote:
    Hi,
    We are planning to install second instance of Oracle 11gR2 in Linux server 2.6.39-400.21.1.el6uek.x86_64 x86_64. This is something we never haven done before. If you have such experience, please give us some insight.
    The existing instance has all the standard ports:
    Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
    Enterprise Manager Console HTTP Port (pterpdb02) = 1158
    Enterprise Manager Agent Port (pterpdb02) = 3938
    What ports should we select for second listener and enterprise manager? Is there anything else that we need to know before we install the second instance?If you want a second database instance, no additional installation is required - as long as you want to run the second instance at the same version as the the first. Just fire up dbca and create the second database. One installation of Oracle (one ORACLE_HOME) is capable of supporting many database instances, though the same may or may not be said of the hardware it is running on.
    As already said, one listener is enough. One listener, running from one oracle home, using the default name of LISTENER, running on the defualt port of 1521, is quite capable of -- indeed, WAS DESIGNED TO, supporte multiple database instances of multiple versions running from multiple ORACLE_HOMEs.
    One instance of dbcontrol/dbconsole will support only one database. If you do not use Grid Control (extra installation, extra license) you will need to use the emca utility or one of the options in the dbca utility to configure a seperate instance of dbcontrol for each database. Don't worry about the ports, the creation utility will take care of it and report what it does.

  • KM Document iView for file download - filename

    Hello,
    we have a hyperlink on our portal logon page for downloading a word document. This link points to a KM document iView. The iView has the property "Path to Document" set to the document in the KM.
    By clicking the link, a file download pop-up appears. But the filename of the downloadable file is the path of the iView - and not the real name of the document.
    Is there any possibility to get the real name as name for the downloadable file? Or should we use another iView?
    Any hint is appreciated!
    Best regards,
    Matthias

    Sorry Tom!
    Your problem seems to be different, I've no idea.
    But we already fixed our problem, I forgot to post. Here's our solution:
    The solution was to create a KM Docs iView with anonymous authentication schema pointing to the download file. Then we created an URL iView pointing to this KM Doc with appending the filename AGAIN to the URL (because otherwise the iView ID will appear as filename). In the page a hyperlink now is pointing to the URL iView and after clicking it, the download starts with the correct filename.

Maybe you are looking for

  • Garageband missing loops like Island long

    Hi there. Last year I took music in school. We used the schools macs on apps like garageband and Logic Pro. I decided to buy myself a mac this year and, after installing the addon loops in garageband, I still only have 2000 loops. I am unable to find

  • How do I find the file name of the current desktop picture?

    I've tried going to System Prefs, right-clicking on the desktop, and rifling through the pictures folder to visually match the picture. Isn't there an easy way to find out what the name of the current desktop picture file?

  • Since Mavericks Update, changing icons just displays generic thumbnail

    Since I updated to Mavericks, I can't change icons without the icon just changing to a generic PNG or JPEG thumbnail (see attached picture). Steps I'm following- CMD + I on the icon I want to change. Copy picture (PNG or JPEG) to clipboard Select ico

  • Problem using portlet's fork render with simplify url servlet

    Hi, I'm creating a portal with bea weblogic portal and for simplify the urls I'm using the example of edocs to do this. http://edocs.bea.com/wlp/docs81/url/simplify.html Everything works fine until i need to use the portlet fork render functionality

  • User license agreement

    hi, I have a Mac OS 10.8.4.  Player Version 11.8.800.94 and a safari browser.  I can download Adobe flash player but when I try to open a document it says I need to agree to the user license agreement, quit, and re open the browser.  I did that and i