Opening .pdf files using a <a href> link - jsf

I have a .pdf document in a folder called docs, that is inside of my WebContent folder.
I want to have a link to show the address to this file, so that when the user click it, he can see the document's content.
The code is this:
See document
When I execute it, I get the error:
HTTP Status 404 - /Web/docs/jsftutorial.pdf
I tested this with a .txt file, and it works, but why not with a .pdf?
Thank you!!

I found a tutorial on how to Read and open the PDF in a new browser window here:
http://balusc.blogspot.com.br/2006/05/pdf-handling.html
Now it works!

Related

What's the equivalent of `imagesdir` for other asset files in Asciidoctor.js?

I have a blog post written as an .adoc with my :imagesdir: set to blank (because the Hexo blogging system sets the post's relative url to the asset subfolder).
All my images load correctly, that's great. E.g.
image::patcher.png[]
But when I try to link to another file in my post's folder like
link:++animation.blend++[Blender project file]
the link is provided from the root of my site (incorrect).
How do I specify the root post folder for asset files, like I do the imagesdir folder for images please?
I asked on the github page too: https://github.com/hcoona/hexo-renderer-asciidoc/issues/9
For the moment, raw HTML is a workaround:
++++
<a href='animation.blend'>Blender project file</a>
++++

How to display an pdf once uploaded with jsf

I have created a file upload function which saves all the uploads to a certain place:
private String destination = "D:/Documents/NetBeansProjects/FileUpload/uploadedDocuments/";
Is this a good place to store it? Should I store it some where else?
Is it possible that once the upload is complete for a page to be displayed showing the user what they have just uploaded, like a box below showing a preview? And how would I go about doing this? I am new.
I have figured it out how to display a plain txt file and an image, however it is the pdf that is confusing me.
As to the upload location, which seems to be the IDE project folder, that's absolutely not right. You should choose a configureable and fixed location somewhere outside the IDE project folder. You should not rely on using getRealPath() or relative paths in java.io.File. It would make your webapp unportable. See also this related question: Uploaded image only available after refreshing the page.
Whatever way you choose based on the information provided in the answer of the aforementioned question (and all links therein), you should ultimately end up having a valid URL pointing to the PDF file in question such as http://example.com/files/some.pdf.
Then, you can serve the PDF file on a webpage using either an <iframe>:
<iframe src="/files/some.pdf" width="600" height="400"></iframe>
Or an <object>:
<object data="/files/some.pdf" type="application/pdf" width="600" height="400">
some.pdf <!-- This link will only show up when the browser doesn't support showing PDF. -->
</object>
Keep in mind that showing PDFs in a browser is only supported in browsers having Adobe Reader plugin. Note that the <object> approach will gracefully degrade to a link when the browser doesn't support displaying application/pdf content.

give Excel file as a link to download in jsp page

How can I give a link to user to download an excel file link on JSP?
my excel will be stored under Web-INF , one folder above my JSP page.
Thanks ahead.
Sample Excel File

Override downloading a file type with Chrome Extensions

I'm trying to build a chrome extension that overrides a download of a file and displays it in the browser. For example if you click on a link to a '.csv' file I'd like it to render in the browser instead of downloading it.
Chrome already does it for PDF's types and the Xml Tree extension also does exactly that for xml files.
So it should be possible, just not sure how to go about catching that event?
An implementation along the lines indicated by in the previous answers and specifically designed for CSV files can be found in this extension of mine on github:
https://github.com/rgrp/chrome-csv-viewer
Furthermore, with the new(ish) chrome webrequest API a direct approach is also now possible along the following lines:
Listen to onBeforeRequest (this has to be in a background script - see background.js)
Check if this is a CSV file (mimetype or file extension)
If so cancel the request and then display the data using xhr
A working version of this can be found in a branch of that extension: https://github.com/rgrp/chrome-csv-viewer/tree/4-webrequest-intercept
You could always look at the XML Tree code :).
If you only need to work with links, and not opening files from the address bar or File > Open, you could build a content script that adds a click event listener to every link.
In the event listener function:
Add e.preventDefault() in the first line to prevent the browser 'following' the link.
Using the link href value, get the data with XMLHttpRequest.
In the XMLHttpRequest callback, open a new tab and render content accordingly.
Obviously, in many ways, this is not a great solution:
you want 'normal' links to be handled as usual by the browser
how can you tell if a text file contains comma-separated values (for example) except by looking at the file extension which, of course, may not be reliable?
Are you specifically thinking of .csv files -- and/or other specific types of content?

I Need Help Modifying CKEditor's Default Image Property Paths

I am using CKEditor with Drupal 6.19. I have tried my installation with both CKFinder and IMCE. When an image is inserted from the image browser into the Image Properties window, CKEditor gets a url similar to:
/sites/example.com/files/images/my_image.jpg
I want CKEditor to simply have:
/files/images/my_image.jpg
file structure of my site is this:
/sites/all/modules/ckeditor/ckeditor
/sites/all/modules/ckeditor/ckfinder
/sites/all/modules/imce
/sites/example.com/files/images/my_mages.jpg
Is this url passed from the file browser, or a default in CKEditor?
If it is CKEditor, where do I find the code to change this, or is it even possible?
The URL suggested /sites/example.com/files/images/my_image.jpg is the correct path. Thats because all files are uploaded to the /sites/example.com/files/ folder. The behavior is correct and should not be modified. (Unless I've not understood your problem correctly or there is a very good reason why you want to store your images under DRUPAL_ROOT/files/images)

Resources