• 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

Struts and dynamic image sources.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi There,
I'm working on an application prototype for a product invenory system.
Part of each products details includes several images (thumbnail, collection of vehicle images).
Image locations (url) are stored in a database and loaded as part of each product image, however, when the image urls are placed within the HTML image SRC tag, the image doesnt display.

1. My html IMG tag is correct.
Generated Tag :
<img src=�http://127.0.0.1:8080/vehicleStruts/testImages/17512_1_th.jpg" alt=�http://127.0.0.1:8080/vehicleStruts/testImages/17512_1_th.jpg� width="100" height="70">
I can copy and past the generated URL into another browser window and pickup the image.

2. My Struts logs state :
ERROR [RequestProcessor] Invalid path /�??http:/127.0.0.1:8080/vehicleStruts/testImages/17512_1_th.jpg" was requested

Has anyone encountered this situation or have any ideas?

Thank.
Rog
 
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the error shows that you have a single slash after the http: (hope you copied and pasted the error message).

regardless, when refering to images that is in a known directory (same goes for shared files such as .css and .js), it's best to use a '/' follows by your application context root then your image directory relative to the context root. in your case it would be "/vehicleStruts/testImages/17512_1_th.jpg" (without the full server name). this is especially helpful when you move application from dev to QA to production. it's also helpful in the case where server name/ip/dns mapping may not be what they appear to be.
 
Roger Moore
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for that.
The server hosting the vehicle graphic will not necessarilly be the sturts app hosting server. How should I handle that ?
(Also, yes its a copy and paste, the app log shows 1 / but the string written to the generated jsp page has // (as shown in 1 above.)

Thanks,
Rog
 
alan do
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
fully qualified URL is necessary in that case.

i am now not sure why the single slash is showing in the error and the "�??" right after it. how did you obtain the server base url? if you hard coded it, could it be that your editor/ide somehow converts the second slash into those weird charaters?
 
Roger Moore
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The URL (in full) is pull back from a db record.

I'm using CMP with a session facade exposed to the struts application.

I make no changes to the string pulled from the DB. Despite the wierd logs... the img src is written correctly to the IMG tag in the generated JSP. I've copied and pasted it into a browser window and the image loads. (lots of head scratching for my part as a result)


Rog.
 
alan do
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it must be the DB encode vs. Java decode...i think. copy from the source and paste it in the browser does not copy the encode/decode as stuff (i really hate) go on behind the Java scene.

can you strip the first 7 characters from the URL in your java code and prepend the http:// as a string after stripping it? if it's some weird de/encoding issue, you'll know.
 
On top of spaghetti all covered in cheese, there was this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic