How can i display image file from absolute path with JSP in Tomcat

1,486 views
Skip to first unread message

EaKG

unread,
May 31, 2009, 1:40:03 PM5/31/09
to Java EE (J2EE) Programming with Passion!
Hi everyone!
i'm creating a web project and i have a folder in a local hard-disk
(ex. D:\image_storage\imagesname.jpg).
But i want to show list of images in jsp but i dont want to copy all
of these images to webapps of Tomcat.
Is it possible ?

Thanks :)

Fitrah Elly Firdaus

unread,
May 31, 2009, 2:00:17 PM5/31/09
to tungn...@gmail.com, Java EE (J2EE) Programming with Passion!
I think it's possible, U can use File class and method in java. But it's
have a high risk. :)

regards

Firdaus

firdaus_linux.vcf

Nguyễn Quang Tùng

unread,
Jun 1, 2009, 3:28:33 AM6/1/09
to Java EE (J2EE) Programming with Passion!
when i do a action upload images , i will store it into local folder
in my PC. Therefore, the size of folder may be quite big. i think it's
possible too, but i resolve this problem not yet.

thanks

Nguyễn Quang Tùng

unread,
Jun 1, 2009, 3:28:33 AM6/1/09
to Java EE (J2EE) Programming with Passion!
when i do a action upload images , i will store it into local folder
in my PC. Therefore, the size of folder may be quite big. i think it's
possible too, but i resolve this problem not yet.

thanks

On 6/1/09, EaKG <tungn...@gmail.com> wrote:
>

Santhosh Kumar

unread,
Jun 1, 2009, 5:58:20 AM6/1/09
to tungn...@gmail.com, Java EE (J2EE) Programming with Passion!
Hi,

You can do this by using java.io.File.

sample code
File file=new File("D:\\image_storage");
File listImages[]=null;
if(file.existrs())
{
listImages=file.listFiles();
if(listImages!=null)
{
for(int i=0;i<listImages.length;i++)
{
//your code goes here, like including in table <table...
<img src="<%=listImages[i].getAbsolutePath()%>" alt="" />
//your code goes here, </table>
}
}
}



regards,
G.Santhosh Kumar



2009/6/1 Nguyễn Quang Tùng <tungn...@gmail.com>

Nguyễn Quang Tùng

unread,
Jun 1, 2009, 11:24:02 AM6/1/09
to Santhosh Kumar, Java EE (J2EE) Programming with Passion!
okay, I have understood. thanks so much :)
Reply all
Reply to author
Forward
0 new messages