cancel
Showing results for 
Search instead for 
Did you mean: 

Images location for Java Application

former_member225041
Participant
0 Kudos

Hi Experts,

I have a java application created in NWDS. Application is having functionality to send an email.Application is deployed in SAP WAS.

I want to use images with message of the mail. For that i want to know where to store images in java application structure.

I dont want to store images on server location. Is there any way so that i can ship images with deployed application ?

Or any other way to store and access images in java application.

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You want your email message contain images and you have images in your application. In that case you have two options:

1. you need to expose images on the web either they are on the EP portal or hosted somewhere on the internet. put the image refrence in the img tag of the message.

2. attach images with your email message and linked the attached images to img tag respective values.

By simple putting images in your application will not be visible in email massage.

Jawed Ali

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Vinay,

If you need only limited number of images to your project you could add them to the webContent folder of your web project and they will be packed in the .war file of your project. Then they will be extracted in the j2ee/cluster/server0/apps/[app vendor]/[app name]/servlet_jsp/_default/root folder.

However if you need to manage large number of images it is better to use a content management system, such as KM.

Regarads,

Ventsi Tsachev

former_member225041
Participant
0 Kudos

It is not a web application. I am creating a folder containing images inside java application structure.But when i am passing the path ,application is not able to identify specified path at the runtime.

Is there any way to store images inside application structure and can be used at runtime.

Former Member
0 Kudos

Hi Vinay,

Assuming that your application is packaged in a jar file, you could add your resources (images) to the jar file. Here's an example: I've created a class ImageLoader in package image and a sub directory image/src. Within the image/src directory I created for demo purpose a simple text file test.txt with some random text. The class ImageLoader then retrieves the file contents via the class method getResourceAsStream:


package image;

import java.io.IOException;
import java.io.InputStream;

public class ImageLoader {
  public static void main(final String[] args) throws IOException {
    InputStream is = ImageLoader.class.
        getResourceAsStream("/image/src/test.txt");
    for (int c = is.read(); c > -1; c = is.read()) {
      System.out.print((char) c);
    }
  }
}

If you run this example it will print out the contents of the text file. The same method you could utilize to retrieve any images you put in the jar file.

Cheers, harald