• 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

How to display image giving dynamic path in HTML

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

My Questions is related to displaying image in html where I need to give a path to image which is not static. For example the image is taken from the database and displayed in html.

<img src="staticlink.jpg/> how to solve this problem?
 
Greenhorn
Posts: 20
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String vis=Long.toString(Total_Visitors);
for(int m=0;m<vis.length();m++)
{
int img=0;
char ch;
String str="";
ch=vis.charAt(m);
//str=ch.

img=Character.getNumericValue(ch);
%>
<td><img src="images/<%=img%>.png" ></td>
<%
}
%>



your problum's solution is similar to this "here i am parsing long to string and for each characeter(1,2 etc) i am showing image as "1.png", "2.png" etc
 
vini chauhan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You! My Problem Solved
 
ripu sudan
Greenhorn
Posts: 20
Tomcat Server Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator






 
Rancher
Posts: 377
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

Your solution works fine while your jsp file is at the root of your application, but what happens when you put that JSP in a subfolder or in the WEB-INF?

Also java in jsps is a big no no! You should be using tag libraries and EL instead.

Sean
 
Sheriff
Posts: 67749
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Re-emphasizing: there should never be scriptlets or Java code in JSPs. That's a poor practice that has been discredited for over 8 years now.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic