9

I may be wrong, but to my understanding, the following must be possible in WildFly:

It must be possible to put a link into my JSF views (i. e. the xhtml files) to a resource (pdf, image, other xhtml file) that is already on the WildFly server.

I can do the same thing in php and an apache server.

Where would I need to put those resources and how can I access them from my views? E. g. put a link in the view to a pdf file that opens the pdf file in a new tab.

Thanks a lot for tips and hints!!

EDIT

standalone.xml

<server name="default-server">
    <http-listener name="default" socket-binding="http" max-post-size="974247881"/>
    <host name="default-host" alias="localhost">
        <location name="/" handler="welcome-content"/>
        <location name="/content" handler="ContentDir"/>
        <filter-ref name="server-header"/>
        <filter-ref name="x-powered-by-header"/>
    </host>
</server>
<servlet-container name="default">
    <jsp-config/>
    <websockets/>
</servlet-container>
<handlers>
    <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
    <file name="ContentDir" path="${jboss.home.dir}/standalone/data/unzipped" directory-listing="true"/> 
</handlers>

link in JSF view

<h:outputLink value="http://localhost:8181/content">KLICK</h:outputLink>

When I click on this, I get the directory listing, as you said.

But how can I make it so that the index.xhtml in the directory that content points to is displayed?? That's really what I want.

content points to ${jboss.home.dir}/standalone/data/unzipped and in unzipped there is an index.xhtml as well as another folder with more .xhtml files.

In the index.xhtml there are relative links to the .xhmtl files in the folder:

<ul>
    <li><a href="t/rt.html">hg</a></li>
    <li><a href="t/tert.html">jghj</a></li>
    <li><a href="t/gf.html">jghj</a></li>
    <li><a href="t/hg.html">jghj</a></li>
    <li><a href="t/hgfh.html">jghj</a></li>
    <li><a href="t/hfgh.html">jhgj</a></li>
    <li><a href="t/hfgh.html">jhgj</a></li>
    <li><a href="t/hg.html">jghj</a></li>
    <li><a href="t/hghh.html">jghj</a></li>
</ul>

I want to display the index.xhtml file in unzipped and from there navigate to the other .xhtml files.

Something like that must be possible, must not it??

Or how else would you write an application where a user can upload html files to a Java ee server and then see those files displayed?

Sevan
  • 669
  • 1
  • 5
  • 18
user3629892
  • 2,960
  • 9
  • 33
  • 64

1 Answers1

13

You may not want to deploy all your static content with your application. These may be images, PDF documents, or other types of files. You should configure Undertow in order to solve this problem. Below example shows you how to do this by configuring Undertow subsytem.

<server name="default-server">
    <http-listener name="default" socket-binding="http"/>
    <host name="default-host" alias="localhost">
        <location name="/" handler="welcome-content"/>
        <location name="/img" handler="images"/>
    </host>
</server>
<handlers>
    <file name="welcome-content" path="${jboss.home.dir}/welcome-content" directory-listing="false"/>
    <file name="images" path="/var/images" directory-listing="true"/>
</handlers>

With this additional configuration, any request for resources to www.sampledomain.com/contextroot/img will be redirected to the filesystem on your hard disk. If you mark "directory-listing" attribute as false, then requests will be redirected as a properly displayed file.

Sevan
  • 669
  • 1
  • 5
  • 18
  • Actually, I would like users to be able to update the static content themselves in a zip file and then access that. If I put my static content in my application, I know how to do it - i just put them in my webapp folder. So according to your solution, I could put a link into my view file (the .xhtml) that points to www.sampledomain.com/contextroot/somefile.xhtml? And in that .xhtmlfile I could have links to othr resources? – user3629892 Dec 23 '15 at 12:32
  • Your question or its title has not contain any statement about update process, so my answer becomes true for the question. I think you should edit your question in order to prevent wrong understanding. – Sevan Dec 23 '15 at 12:53
  • Yes, your comment is right. Your .xhtml files could point any pdf, image or another xhtml file, but pointed files will be shown as filesystem on your hard disk. – Sevan Dec 23 '15 at 12:59
  • Yeah, sorry about that!! Thanks for your answer! – user3629892 Dec 23 '15 at 13:36
  • I tried your answer and edited my question. I would be really cool if you could have another look or share your thoughts and ideas! – user3629892 Dec 23 '15 at 15:45
  • Change only directory-listing attribute from true to false in file handler which name is "ContentDir" and try again. html files must be displayed properly. – Sevan Dec 23 '15 at 18:34
  • I dont know why it didnt work the first time but it works now!! I was probably just to desperate and annoyed :D Thanks a lot!! Enjoy the holidays and have a good new year! – user3629892 Dec 23 '15 at 20:49
  • I will be more happy, if you could accept my answer as most helpful. Have a good new year, too :) – Sevan Dec 23 '15 at 21:01