Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Servlet forward JSP, image problem

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using servlets for db operations, etc. and jsp for presentation. But, when I do a forward from a servlet to a JSP, all the image, css, etc. paths keep with the servlet URL (the browser dose not know about the forward, i guess).
I used a propertie to set this path in the jsp, so I have <img src="<%=prop.IMG_PATH%>/x.gif>, but it becomes dificult to edit the Graphical design, so, Is there a better way to do this and keep the relative path of the images ?.
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I recognize your problem, I've encountered it myself a few times. I can only say that the solution I came up with is more or less the same as the one you have (keeping the path from the web context stored in a constant or property)... It seems that if you do a forward every notion of 'current location' in the web app is gone....
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HTML provides a BASE tag that you could put in your JSP to define where resouces such as CSS and images come from. A BASE tag goes in the HEAD area of an HTML page like:

now any relative url for an image will be interpreted by the browser as coming from that base.
Bill
 
Jaime Garcia
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, good solution
 
Paddy spent all of his days in the O'Furniture back yard with this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic