• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

common image path

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
We plan to define path-variables wrt to the static components in our application.
e.g. We have 1) a variable image_path for all images in <app>/images/
2) a variable css_path for all .css stylesheets in <app>/css/
etc. etc.

We have thought of a strategy: define all variable declarations in a settings.jsp and include this jsp in all other subsequent jsps.

But we are not able to get the values variable when html is rendered. The values of all variable in subsequent jsps is printed as "" (empty string)

Here is the part related:

settings. jsp -
...
...
<%String url =(String) application.getInitParameter("MyApplication");
// The value of url when printled here is "/myapp"
String images_url = url + "/images";%>
...
...


app.jsp
...
...
<%@ include "settings.jsp" %>
<html:img src="${images_url}/folder/logo.jpg" />
...
...

When executed, this results with src containing a value "/folder/logo.jpg" instead of "/app/images/folder/logo.jpg"

Thanks in advance

Sachin
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In order to use a variable in an EL expression such as ${images_url}, you must put the variable in a scope (page, session, request, or application). Example:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic