Display image from some server directory - jsf

I save uploaded image files in tomcat or portlet temporary directory, and I want to display them. I know their path in server file system, but how generate a right path for displaying it on portlet's page? It must become from smth like:
opt/liferay/tomcat-7.0.27/temp/28-Image-portlet/WEB-INF/classes/intech/webpro/kegor/image/Clipboard02.jpg
to
http://test.com/web/guest/liferay-benefits?p_p_id=Image_WAR_Imageportlet&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_cacheability=cacheLevelPage&p_p_col_id=column-1&p_p_col_count=1&_Imag
How to get it?
I know how it is done from portlets resources folder:
#{resource['images:smiley.jpg']}
But how to display image from some server directory in portlet?

You can't access images from another server using #{resource['image']} ,
You can either
1) give the full image path in xhtml
2) Keep the image paths in CSSfile and use CSS classes in xhtml.
3) create a common util function or
ResourceHelper ApplicationScoped Bean that has something like
getResource(String imageName) which returns the correct URL. You
can then use it in your xhtml as
#{ResourceHelper.getResource('image.png')}

If you only need to display content (without permission check), you can use Tomcat. Put file into /webapps/portlet-name/html/ (or temp/portlet-name/html/) directory.
As a result: http://site.com/portlet-name/html/image.jpg

Related

Why URL's "path" such as index.html was hidden?

In modern Website usually hidden path.
use this
https://google.com/main
instance of this
https://google.com/main.html
but I want to ask why they chose to hidden the file path.
I know that Initial web was use this file path.
But if they chose to cover up it, I think there was some reason.
Because of they just think it doesn't look good?
Or is there a security issue when using a file root?
in tranditional website.all content on the page is static and write in html file.so we can fetch and show the page directly by browser.
in modern internet,the content we browse is dynamic,for example we browse a news page,the content changed every second,so the server handle our request by some function not handle by a static html file,the function always print out latest news,so it is dynamic,not a unchanged static html file.

Creating a custom url for an static html page

I need to create a page like http://www.example.com/strong and the file to support that are inside my docroot/strong/index.html.
Inside my docroot there are other folders with their index file as well. For example
docroot/site1/index.html
docroot/site2/index.html
docroot/strong/index.html
So when user types in http://www.example.com/strong it should open docroot/strong/index.html without changing the URL. Can I achieve this?

When render a .jade, Node.js cannot find the static files

Enter image description here
It's OK that I can get files in directory public when get localhost:3000/movies, but if I add / to the end of URL, that is localhost:3000/movies/, something goes wrong, the CSS file in public cannot be get. How do I solve this problem if I want to visit localhost:3000/movies/moive with CSS style?
When you are at localhost:3000/movies, think of being in "folder" / and viewing "page" movies. If you are in localhost:3000/movies/blah or in localhost:3000/movies/ then you are viewing pages blah (or / respectively) in the movies location.
The above is true regardless those "pages" exist or not; most likely you just have express route handlers and jade templates structures differently -- but the rationale works for the browser and the requests to absolute URLs it will be performing.
So I cannot say what is wrong without looking at your pages code, but make sure all relative paths (e.g. linking to a CSS file foo/bar.css) are valid from all locations, or alternatively use absolute locations (e.g. /foo/bar.css).

Tomahawk MyFaces File Upload Component not showing on screen

I am trying to use tomahawk MyFaces file upload component t:inputFileUpload. I followed the example at JSF 2.0 File upload, with one change-instead of copying files to /lib, I used maven. There are no errors or warnings, but the file upload component is not showing up. Only the submit button shows on the screen. Please help me
Check the rendered HTML page. Perhaps it still contains <t:inputFileUpload>. In this case you may have forgotten to add the namespace for the prefix t to your file like this:
xmlns:t="http://myfaces.apache.org/tomahawk"
If the prefix isn't defined, the tags are simply not processed and directly rendered to the output.

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