• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

common image path

Posts: 20
  • Mark post as helpful
  • send pies
  • 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";%>

<%@ 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

Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • 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:
F is for finger. Can you stick your finger in your nose? Doesn't that feel nice? Now try this tiny ad:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic