Path of the image field

Hello

My version of jdev is 12.1.3.

I created a class file NewMail in view viewcontroller package.

During the validation operation, I'm lance an email of the display according to the code below.

MSDS of DataSource = new FileDataSource)

"Picture.png");

If I give the full path for picture.png, I am able to get the mail with image.

ADF survey null pointer exception if I don't give the full path, how generalize as by ADF incase if I decide to put this picture.png inside the contenuWeb folder.

package view;
import java.io.File;


import java.io.InputStream;


import java.util.Properties;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;


import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;


import oracle.jbo.domain.ClobDomain;




public class NewMail {


    public static void sendenhancement_mail(final String user ) {
       Runnable r = new Runnable() {
               public void run() {
                      
                          try{
      String to = "[email protected]";


      String from = "[email protected]";
      final String username = "[email protected]";
      final String password = "rrrr";


      Properties props = new Properties();
       props.put("mail.smtp.host", "rrrrr");
       props.put("mail.smtp.socketFactory.port", "333");
       props.put("mail.smtp.socketFactory.class",
                       "javax.net.ssl.SSLSocketFactory");
       props.put("mail.smtp.auth", "true");
       props.put("mail.smtp.port", "333");
      Session session = Session.getInstance(props,
         new javax.mail.Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
               return new PasswordAuthentication(username, password);
            }
         });


      try {


         Message message = new MimeMessage(session);


         message.setFrom(new InternetAddress(from));


         message.setRecipients(Message.RecipientType.TO,
            InternetAddress.parse(to));


         message.setSubject("Hi");


         MimeMultipart multipart = new MimeMultipart("related");


         BodyPart messageBodyPart = new MimeBodyPart();
         String htmlText ="Hello"+"<img src=\"cid:image\">"+"<BR><B>Note: This is an automated E-mail.</B>";
         messageBodyPart.setContent(htmlText, "text/html");
         multipart.addBodyPart(messageBodyPart);


         messageBodyPart = new MimeBodyPart();
          System.out.println("Working Directory = " +
                        System.getProperty("user.dir"));
         DataSource fds = new FileDataSource(
            "Picture.png");


         messageBodyPart.setDataHandler(new DataHandler(fds));
         messageBodyPart.setHeader("Content-ID", "<image>");


         multipart.addBodyPart(messageBodyPart);


         message.setContent(multipart);
         Transport.send(message);


         System.out.println("Sent message successfully....");


      } catch (MessagingException e) {
         throw new RuntimeException(e);
      }
       }
       catch (Exception e) {
                                          System.out.println("Exception occured "+e);
       
                                      }
       
       }
       };
       
       Thread t = new Thread(r);
       t.start(); 
   }
}

If the files that are part of your web application, you can retrieve it with something like:

InputStream is = this.getClass().getClassLoader().getResourceAsStream("/RELATIVE-PATH/yourFile");

or

FacesContext fc = FacesContext.getCurrentInstance ();

ServletContext sc = (ServletContext) fc.getExternalContext () .getContext ();

Path String = sc.getRealPath("/RELATIVE-PATH/yourFile")

(you must enable "Enable getRealPath() results for archived web applications")

ACCESS RELATIVE path is relative to the root of the context (something like "/ images")

Dario

Tags: Java

Similar Questions

  • How to bind dynamically image with a path to the image?

    XML given by path of the image. How to link to the image field in adobe livecycle?

    Try the LiveCycle forums...

  • Path of the image that appears as a ToolTip in the PDF documentation

    Hi all

    I posted this problem some time ago, and I gave him also the solution of filling of the ToolTip for the image in the image properties, but it works for RH7, while for RH8 it does not matter what I enter in the ToolTip, it will always display the full path of the image at the time of the creation of the PDF file giving some sensitive information away. Do not have not the ToolTip specified in the properties of the image, this is certainly a bug. Is there a cure for this. Basically I didn't need no ToolTip for my photos. Better would be to not display anything either, but it seems impossible for now.

    It doesn't matter if I generate the PDF file as a layer in RH8 or I generate it from Word, the result is the same and it's annoying.

    I hope there is a cure for it.

    I use a Windows XP Pro 32-bit and I installed all service packs of Adobe.

    Thank you

    Bogdan

    REPLACE GLOBAL has been in HR for a while, certainly it's in RH7.  It is not very user-friendly because it has not automactically go to the path for the project that you have currently open (listen to you Adobe?).  I call it REPLACE OVERALL because it was called that at some point in the history of HR (I used several years now), but is not actually called that now.

    HRE is how it works in RH9 (and I remember works the same way, but the name may be different in RH7):

    In main menu: select EDITION > SEARCH AND REPLACE the FILES in

    This opens a dialog where you fill in the SEARCH and REPLACE.

    Make sure that the NAMED field has *.htm.

    Notice in the field WHERE you need to go THROUGH the folder for the project that you have currently open and also INCLUDE the subfolders is enabled.

    Click on FIND and more options is displayed, how you can choose to REPLACE ALL >

  • Retrieving error - could not find the path of the image... M:/RecoveryImage/install.wim

    So, I went out and bought the USB on the gateway site to restore this laptop again and when I tried to do, he says recovery failed - could not find the path of the image M:/RecoveryImage/install.wim.

    I contacted support and they issued me a replacement USB drive, I get the same failure.

    I diagnosed the HARD drive and it passes.  I used diskpart to 'clean up' the disk drive HARD all nothing doesn't.

    [Under the direction of privacy] order number

    What gives?

    Acupro1,

    I you sent a PM with respect to research purposes.

  • Get the path of the image of the contact for smartphone webworks

    Hi all
    I'm trying to get the path of the picture of the contact in the address book.
    I get the title, first name etc with success.
    But I can't find such a code I can get the path of the image of the particular contact.

    Please help me if anyone knows the code or have any solution as soon as Possible.

    Thank you best regards &,.
    Castillo

    You can retrieve the image encoded base64 string object, but will not receive the path of the file (The API Reference). To display the image, you can use a URI of the data with a tag.

    Example on how to use the data URI: http://css-tricks.com/data-uris/

  • How to change the image field captures screenshots automatically from BMP to JPEG

    How to change the image field captures screenshots automatically from BMP to JPEG

    I want to say, when I tap on the screenshot on my keyboard and paste this image in microsoft photo editor or picasa 3.0 areas of the bitmap .bmp. instead of asking the witch I´d field prefer.
    So, I open that image on the brush to convert it to. JPEG.
    It's hick very!
    is it possible to easily me this step and save or paste pictures in JPEG on my files automatically?

    Hello

    I saw that article when I was looking for one that I posted...

    I understand your problem, and the answer is that, to the best of my knowledge... NO..

    Windows records the capture in memory as bitmap, along with, even if you can paste it directly into a folder, it would be in the form of bitmap...

    The best I could find is to use the suggestion in the link I've included which refers to the

    Windows Key + PrintScreen to automatically record is in PNG format in your pictures folder...

    The only way to do what you want is with a 3rd party capture program that can be configured to save in a directory as a specific file type...

    Personally, I use a program called print screen Deluxe for this... it is a purchased program...

    I'm sure you could find something free to do what you need...

    You may need to use a different key for print screen, but the software can allow you to reprogram the PrntScrn key...

  • What happened to the image field when you create a field of type of image for the Web application?

    What happened to the image field when you create a field of type of image for the Web application?

    The answer is that the point of the IMAGE has been changed to the MEDIA.

    Sorry, Ian, what research for this discussion, I got no results. All good and thanks for the carillon. Hope everything goes well.

    Mouma

  • How can I hide or delete the path to the images in PDF format?

    I create a document in Word, and then convert it to PDF.

    Once published and downloaded online, when I move the mouse over an image, the path to the image file is displayed.

    How do I hide or remove this, so it is not displayed?

    My partner got figured out. No need to answer.

  • path of the image broken after upgrade 4.1 and 4.2

    Hello

    Just upgraded multiple instances of 4.1 to 4.2.1. Running apex listener 2.0.0.354.17.05 on glassfish 3.1.2.2. Our database is 11.2.0.3.0 on centos 2.6.32 - 279.9.1.el6.x86_64

    One of our updates have a very unusual problem. Our applications everything will work perfectly, but the generator screens are empty, or at least appear empty. The source of the page looks normal in a browser, except we are seeing that the image paths are all poorly trained. They all lack the directory ' / ' final after the 'i' of the images. For example, the login page of the generator has the reference of the following image:

    https://ourorg.org/iapex_ui/apexlogo.PNG

    who should be

    https://dev.insitehome.org/i/apex_ui/apexlogo.PNG

    If I type the correct URL, the image is visible, so I doubt there is any problem with the version of the images or the location of the server. Apex SEEMS to generate the incorrect path for the images.

    Any suggestions?

    Thank you
    Steve

    stevepence wrote:
    OK, it seems pretty obvious what happened. Instead of

    @apxrtins.sql SYSAUX SYSAUX TEMP /i/
    

    I dropped this trailing slash after the 'i '.

    I hope someone can tell me where in the apex metadata to fix this without reinstalling.

    Run the /apex/utilities/reset_image_prefix.sqlscript, but make sure that they have set Re: 4.2 reset an error sql prefix image. If this isn't the case, apply the workaround before you start.

  • The path for the images of attachment in RoboHelp 8

    I'm pretty new to Robohelp, so please forgive me if this has been addressed in another discussion... I have looked and can't seem to find what I'm looking for to describe.

    I work in Robohelp 8 and creation of a new help system in important subjects to a former aid system. The problem, I'm running in and I don't see how to solve is that there are a few topics that have images where instead of the path of the image to a folder called "Images" in the main directory, it plunges the graph in the Project Manager window when I import the subject. I tried watch a subjects who do not have their images in the window of senior project manager, and compared with that, and I don't see the difference. I tried to rename the images and placing them in the correct folders and then insert the images in the topics, but he always tries to look at the main folder and rest pours out the image in the project manager.

    Please share any help you can provide.

    Right-click on the project files and add a new folder called Images. The images probably will appear.

    You do not have to have images in the same folder as the subjects, it is up to you, where they are stored. When project files shows, you see the real records and you can store things where you want. When you see the HTML files, RoboHelp shows the old view with Nick records. I suggest you stick with project files and then have the images where you want.

    See www.grainge.org for creating tips and RoboHelp

    @petergrainge

  • Questions to set the path of the image for the data merge in indesign

    Hello. I have problems to define the path to the image properly to merge images into my document. The data merges correctly, then not issued with the source file, but the images will not bind. Have tried serval variables: for example including with and without the "Machintoch HD" root directory path and "/" and with ":" and with the name of folder only. A copy path directly from indesign links Panel. At a loss. Am I missing something simply or is it too complicated?

    can any help?

    No problem! I was almost afraid to ask because it seemed too obvious! I'm so glad I did... Please mark it as "Answered."

  • Is there a way to hide the? symbol, if the recording of the image field is empty?

    If that makes sense...

    Basically, I put a page of details about a site that allows the owner of the site display up to three images. However, sometimes they will download only one or two images.

    Currently, that looks like this:

    http://www.travel7107.com/destinationDetails.php?destinationID=57

    Is it possible to get rid of the small? icons where the image field is empty?

    I tried to download a small white image, and affecting the blank.gif than the default fields, but the file download the script seems to crush those who have a blank if no picture is selected to download.

    So for the moment I have them given this small image to use if they have not the images, but it would be nice to know if there was a way to avoid this step?

    Try

    <>
    If ($row_WADAdestinations ["image_2"]! = ")
    echo '';
    ?>

  • The image field by repeating the subform

    I created a flyer and wanted the opportunity to capture images on the fly.  Well, I used an image to do this field, however, users should be able to insert images up to 4.

    I know that the way to do it is a repeating subform if I put the image field in one and set the options of "repeat... etc.; 4 max; 1 count.  I added a subform control that is embedded with livecycle to add/remove fields.  Well, after testing... it does not work... Nothing happens when I click on + or-. In addition, I have to be able to have the repeating image field to the right or to the left of that already there appear and then have both centered horizontally on the page...

    The form is a type of "missing persons" form so I need he's as crazy as possible evidence to users.  I do not know how to download the form, but is - anyone out there who knows more that I willing to help? I can't understand what I'm doing wrong.  The form is also complete with the exception of this little problem...

    Thank you

    Brenda

    By default, the subforms are defined broadband down. You can change to the flow of Western text (from left to right). This setting is on the Subform subform objects tab and it is called flow direction (of course it will appear only on subforms went down).

    Paul

  • path of the image file that links do not correctly in the executable file

    I have a jpeg file in a project that I'm building which is not loading when run as an executable file.  The executable seems to be looking in the same directory that the image file was originally instead of the support folder where the image is deployed.  On another machine, the exe will look for the image in the directory, that were found on my machine.  When I drag the image file of the project on the block diagram Explorer, it creates a constant path of file indicates where the file is located on my machine.  This does not seem to update when I build the exe.  The image file is included in the source files.  Any help is appreciated!

    A constant path is... Yes indeed constant! It's not automatically change whenever someone might move the file too, whatever his imagination made her do. He does not maintain a link to the actual file it could use later to detect that the file has been moved elsewhere. In fact Windows has quite such a mechanism.

    So if you want to access an external file to your executable application to first do a correct path when running. My approach is to put in a directory from a VI file that I put in my application. Then in this VI use the way of getting current VI, band name the VI of it and add the location relative to the other file to it.

    If you do something like this:

    The project directory

    Directory of the utility

    My Location.vi

    Data directory

    MyResource.jpg

    in system development, then:

    The application directory

    MyApplication.exe

    Data directory

    MyResource.jpg

    in the application of the construction.

    With this provision, it doesn't matter even if you use the old format of executable LabVIEW 8.x or the new default format since LabVIEW 2009.

    My Location.vi is just a VI that takes a relative path in the entry (in this case "... / directory/MyResource.jpg data" called the "Current path to VI" node, use 'Band path' to remove the name of VI, then build to add this entry path, and this is!.)

  • Unable to get the path of the image

    Hello

    I get a picture from the pictures folder. Set it on my screen - so I have the byte []. I want to store the image on the phone and I find it difficult. I surfed for this problem and found a lot but this code is not working. I guess, I made a mistake somewher, can someone point me to where and what error.  The code is:

        // Save the selected photo to a specified loaction on mobile
        public static String SavePhotoToPhone(byte[] photo) {
            String path = "";
            String p = "fileconn.dir.memorycard.photos"+"picture2.png";
            try {
                FileConnection fc = (FileConnection) Connector.open(System.getProperty(p), Connector.READ_WRITE);
                if (! fc.exists())
                    fc.create();
                OutputStream oStream = fc.openOutputStream();
                oStream.write(photo);
                oStream.flush();
                oStream.close();
    
                path = fc.getURL();
    
                System.out.println("PHOTO PATH SET = " + path);
    
                fc.close();
                fc = null;
                oStream = null;
            }catch(ConnectionNotFoundException ce) {
                System.out.println("SavePhotoToPhone-Connection to the File cannot be achieved: " + ce.getMessage());
            } catch(IllegalArgumentException ile) {
                System.out.println("SavePhotoToPhone-Invalid Path or So | Key is Empty: " + ile.toString());
            } catch(IOException ie) {
                System.out.println("SavePhotoToPhone-Firewall Problem | File does not exists | Taget not accessible: " + ie.getMessage());
            } catch(IllegalModeException le) {
                System.out.println("SavePhotoToPhone- Cannot Write : " + le.getMessage());
            } catch(SecurityException se) {
                System.out.println("SavePhotoToPhone- Permission not Granted to Write: " + se.getMessage());
            } catch(NullPointerException ne) {
                System.out.println("SavePhotoToPhone- System key is null: " + ne.getMessage());
            }catch(Exception e) {
                System.out.println("SavePhotoToPhone- Exception : " + e.getMessage());
            }
            return path;
        }
    

    It is throwing exception IllegalArgumentException. I used the same code, as provided for by mantaker on http://supportforums.blackberry.com/t5/Java-Development/how-to-save-encodedImage-on-disc/m-p/215531#...

    I want to record on the phone. I guess that my property is false. The Simulator will not have any memory card, then how do I save it? With the code above, I should also get the path of the file proeprly or not?

    Thank you

    You can create your own file in the blackberry's internal file system.

    Use the url file:///store/home/user

    Under user folder, you can create your own little ones, for ex:

    file:///store/home/user/myFolderOne

    file:///store/home/user/mydata/myDataOne

    etc.

Maybe you are looking for