File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes How to display image giving dynamic path in HTML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to display image giving dynamic path in HTML" Watch "How to display image giving dynamic path in HTML" New topic
Author

How to display image giving dynamic path in HTML

vini chauhan
Greenhorn

Joined: Dec 07, 2010
Posts: 5

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?
ripu sudan
Greenhorn

Joined: Dec 07, 2010
Posts: 20

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

Joined: Dec 07, 2010
Posts: 5
Thank You! My Problem Solved
ripu sudan
Greenhorn

Joined: Dec 07, 2010
Posts: 20







Sean Clark
Rancher

Joined: Jul 15, 2009
Posts: 377

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


I love this place!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to display image giving dynamic path in HTML