Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Al Hobbs
  • salvin francis

Securing URLs

Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a Struts related query.
In my web app, I have a folder named XX which has two files, Show.html and Game.swf, with the Show.html having the code to show the swf (Game.swf) file. This folder XX is in no way related to the web app. In a page in the web app, I have to point a link "GAME" to Show.html.
The folder XX exists outside WEB-INF and I coded as:
<a href='/XX/Show.html'>GAME</a>. The code worked well.

But the problem is the URL appeared on the browser bar as http://localhost:8080/XX/Show.html. So, with the idea of securing the URL, I planned to use an action named with the following mapping in the struts-config file:
<action path="/ShowGame"
type="org.apache.struts.actions.ForwardAction" />
and changed the href code to:
<jaf:link action='/ShowGame'>GAME</jaf:link>
This is not working.

Can you please tell me why?
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem here is that by doing this, you have changed the current directory from /XX to /. This means that /XX/Show.html can no longer find Game.swf.

You can fix this by putting a <base> tag at the beginning of your html document:

<base href="/MyApp/XX/Show.html">

Then, any references to "game.swf" will be resolved correctly.

If you want to avoid hard-coding a reference to the context root, change the page to a JSP, and use the Struts <html:base> tag.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic