relative path traversing, is this valid? - path

I have a an XML file where I need to get up 2 dirs to get a file (from water to fire)
<album basepath="albums/water/images">
<img src="001.jpg" />
<img src="002.jpg" />
<img src="../../fire/images/005.jpg" />
</album>
So my question is if
albums/water/images/../../fire/images/005.jpg
is a valid path?

Yes, it's a valid path

Related

Why I get error when I try to display image?

I work use asp.net mvc5 in my project.
I try to display Image stored in my Shared folder in the project:
<img src="#Url.Content(~/Views/Shared/logo.png)" alt="" />
But I get this error on the fly:
Compiler Error Message: CS1525: Invalid expression term '/'
Any idea why I get the error above?
#Url.Content helper needs string as a parameter so you should write like this:
<img src="#Url.Content("~/Views/Shared/logo.png")" alt="" />
or you can use single brackets
<img src='#Url.Content("~/Views/Shared/logo.png")' alt='' />

Can we use path values in <path path="..."> in page-flow.xml without wildcards?

I have a sample application hello-world with two files.
page-flow.xml - with wildcard in path
<controller xmlns="http://www.orbeon.com/oxf/controller">
<page path="*" view="hello.xhtml"/>
</controller>
hello.xml
<html>
<body>
Hello world!
</body>
</html>
If I enter http://localhost:8080/orbeon/hello-world/hello in the browser it works as expected.
If I replace the path argument with a specific path value, I get an Orbeon Forms Page - Page Not Found, though.
page-flow.xml - without wildcard in path
<controller xmlns="http://www.orbeon.com/oxf/controller">
<page path="/hello" view="hello.xhtml"/>
</controller>
Any idea what is wrong here?
The path that must match is /hello-world/hello, not just /hello. So try instead:
<controller xmlns="http://www.orbeon.com/oxf/controller">
<page path="/hello-world/hello" view="hello.xhtml"/>
</controller>

Render different Code for Each Request | Random | Split Testing

I'm searching for a solution for a simple Split Testing (without statistics).
Basically for each request I want a different image to be rendered.
<div class="hero-panel">
<img src="test1.png" alt="img" />
<!-- or -->
<img src="test2.png" alt="img" />
<!-- or -->
<img src="test3.png" alt="img" />
</div>
Per request, one of the 3 images. Has anyone a good solution for this ?
you can select a random image between these three by
<img src= "<%=['test1.png', 'test2.png', 'test3.png'].sample%>" alt="img" />

MVC 3 - _Layout.cshtml. Add a logo to the site

I'm new to MVC 3, I'm trying to add an Image to the _Layout.cshtml file.
I tried
<img runat="server" id="img_logo" alt="Logo" src="Content/Images/mailworks.png" />
no success. The logo only appear on some views. on others views for some reason the image is supposed to be in some other location - found it using firebug.
Try this:
<img id="img_logo" alt="Logo" src="#Url.Content("~/Content/Images/mailworks.png")" />
Use this:
<img src="#Url.Content("~/Content/Images/mailworks.png")"...
I found another quick solution : just append '/' at the beginning of the src's path.

Where are the pictures of my JSF page?

I have a navigation-rule like this in my JSF 2 application:
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-action>#{myBean.goToMyHome1}</from-action>
<from-outcome>myHome1.xhtml</from-outcome>
<to-view-id>/myhome1/myHome1.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
When I put an h:commandLink in myHome2.xhtml within directory myhome2 that satisfy this rule, the page myHome1.xhtml will display but there are no images on the page. Where they go?
Behind the application is Springsecurity 3 with this config:
<sec:intercept-url pattern="/myhome1/**" access="hasAnyRole('ROLE1','ROLE2')" />
<sec:intercept-url pattern="/myhome2/**" access="hasRole('ROLE2')" />
This look like as if your picture URLs are relative to the current URL path. E.g.
<img src="images/picture.png" />
When you open the page by
http://example.com/contextname/myHome1.xhtml
then the image URL will effectively point to
http://example.com/contextname/images/picture.png
But when you open the page by
http://example.com/contextname/myhome/myHome1.xhtml
then the image URL will effectively point to
http://example.com/contextname/myhome/images/picture.png
You need to fix it accordingly. There are several ways. Use a domain-relative path
<img src="/contextname/images/picture.png" />
Or prepend the context name dynamically
<img src="#{request.contextPath}/images/picture.png" />
Or just use <h:graphicImage> which will do that automatically
<h:graphicImage value="/images/picture.png" />

Resources