Displaying HTML file using IFrame

Hi All,
I have an HTML file in my par file. It is contained as dist\html\test.html. Now I want to display this inside an IFrame. If I try something like
<iframe id="myIframe" src="html\test.html"  width=100% height=100% frameborder="0"></iframe>
it fails to load the HTML file. Please let me know how to display this.
Thanks in advance
Shubhadip

Hi George,
as per your suggestion I have used
<% String html = componentRequest.getWebResourcePath() + "/html/test.html";%>
<iframe id="myIframe" src=<%=html %>  width=100% height=100% frameborder="0"></iframe>
But its not working.. giving the following error:
Portal Runtime Error
An exception occurred while processing a request for :
iView : pcd:com.sap.portal.system/temporaryobjects3/9b20d054b8a1ab8c2cd5d105cde1788c/TestDynPage
Component Name : null
Page could not create the iView.
But if I give some web url like yahoo.com it works fine. How to do it then?
Thanks,
Shubhadip

Similar Messages

  • How to display HTML files using ABAP Webdynpro?

    Hi,
    I have a html index file and a bunch of other files accessed by the index file  in a specific directory on the SAP server. I'd like to display the index file via ABAP webdynpro and allow the users to click on what they need to see. How can I achieve this using utilizing the ABAP webdynpro technology ?
    Thanks!

    Hi Thomas,
    Thanks for taking the time to answer my question.
    I have the main html file and all other files needed by the main file in one directory on the application layer of SAP. I'd like to provide the user with a link, by clicking on which they should be able to get to the main html file using the browser. This is just a standalone application.
    I can try the approach using BSPs, however, I'm new to that area. Could you point me in the right direction to get started?

  • How to display HTML file from Unix server on UI at runtime

    Hi Experts,
    My requirement is to display  HTML files,  related to some particular person, on UI. The file is existing on a separate UNIX server and a file related to one person may have a lot of attached files as well , as is the case generally with HTML files, including pictures etc. So it is no use transferring file on my CRM system, as the files are kept separately on this UNIX server which is particularly for this kind of storage.
    I am able to show files residing on MIME repository ( I created some new HTML files )  of my CRM system on UI. but I don't know how to go ahead with this particular requirement.
    One idea is that I can map one folder of my application server to that unix server so that I can see the HTML files in this particular folder. but I don't know how to map MIME repository folder to application server directory or directly to the UNIX server .
    Please advise. Is my approach correct or is there any other way ?
    thanks in advance.
    Regards,
    Vikas

    Maybe this is too simple, but have you got an HTTP server on the UNIX machine? You could simply link the URL into you CRM application and display the contents directly from UNIX.
    cheers Carsten

  • Edit HTML File using java

    Hi....
    I have a report in HTML format and a list of thresholds in txt format.
    Now, using java how can I:
    1. Compare the values in the report with the thresholds
    2. Edit the report such that values over the thresholds are highlighted in say, red colour.
    I am new to Java programming, so java jargons won't be of much help. I read about jeditorpane but it's primary use is to display html file(that is what i inferred). Is their a way in which i could accomplish the above using jeditorpane??....how do i do the comparison part??

    srgsoroka wrote:
    Did you check http://jtidy.sourceforge.net/.
    From site:
    "JTidy is a Java port of HTML Tidy, a HTML syntax checker and pretty printer. Like its non-Java cousin, JTidy can be used as a tool for cleaning up malformed and faulty HTML. In addition, JTidy provides a DOM interface to the document that is being processed, which effectively makes you able to use JTidy as a DOM parser for real-world HTML."Yes, I did. But I don't need a syntax checker.The syntax is alright. I want to modify the HTML code after comparison with a txt document.As far as DOM parser is concerned, I googled the term but didn't understand much of it..:-(...If you could explain it in layman's terms........

  • How to parse a HTML file using HTML parser in J2SE?

    I want to parse an HTML file using HTML parser. Can any body help me by providing a sample code to parse the HTML file?
    Thanks nad Cheers,
    Amaresh

    What HTML parser and what does "parsing" mean to you?

  • How to read HTML files using UTL_FILE

    Hello Friends,
    How to read HTML files using UTL_FILE package ? According
    to Oracle documentation UTL_FILE can read or write OS Text Files.
    Thanx in advance..
    Adi

    HI Hareesh,
    i have gone through that blog.
    i tried it...but i am getting mapping error  no receiver determination fond because there are so  many excel files.
    my data is available on sharedString.xml but also it is in not same order.
    i have no clue how to handle this part form the blog.
    "This way our mapping will receive all data from the sheet in an XML format. The only thing that's left is to create an XSD file from the XML file we received in order to be able to use it in the mapping and as our Service Interface and we can proceed with mapping. As you can see from the sheet.xml files all the data is placed with column name and row number so it's not that difficult to map it to an table type format using the Message Mapping only (no java, abap mapping required)."

  • How to put HTML file in IFrame?

    I want to put HTML file in  IFrame. what i will do? please give details...

    Hi
    Copy the HTML file into your x:\<project name>\src\mimes\components\<your package name>\<your html>.html
    after that in NWDS -- > <b>IFrame</b> --> <b>Source</b> property just type <your html>.html
    Regards
    Chaitanya.A

  • Opening HTML file using a Jbutton

    can anybody tell me how can I open an HTML file using a Jbutton.
    I have a help button on my menu of my GUI. I wanna open a html document using the help (jbutton)
    thank you

    call this class in your button action
    import javax.swing.JInternalFrame;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.net.URL;
    import java.net.MalformedURLException;
    import java.io.*;
    import javax.swing.text.*;
    import javax.swing.JOptionPane;
    import javax.swing.BorderFactory;
    import javax.swing.border.*;
    import javax.swing.JDesktopPane;
    public class Taa extends JFrame implements HyperlinkListener{
         public JEditorPane hh;
         public JScrollPane ss;
    *Taa default constructor
    *@param Nothing
    *@return Nothing
    *@thorws nothing
    *@see descon
    public Taa(){
    //set top left image in the gui
    setIconImage(Toolkit.getDefaultToolkit().getImage("buttons/help.jpg"));
    try{
         File f=new File("Here you can put your html"such as"Help.htm");
         String s = f.getAbsolutePath();
         s = "file:"+s;
         URL url = new URL(s);
    hh=new JEditorPane(s);
    hh.setEditable(false);
    hh.addHyperlinkListener(this);
    catch (MalformedURLException e) {
         System.out.println("Malformed URL: " + e);
    catch (IOException e) {
         System.out.println("IOException: " + e);
         ss=new JScrollPane(hh);
         getContentPane().add(ss);
         setBounds(232,0,490,500);
         setResizable(false);
         show();
    *Implementation of HyperlinkEvent
    public void hyperlinkUpdate(HyperlinkEvent e) {
         if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
         linkActivated(e.getURL());
    *this method activate link
    *@param URL the URL
    *@return Nothing
    protected void linkActivated(URL u) {
         Cursor c = hh.getCursor();
         Cursor waitCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
         hh.setCursor(waitCursor);
         SwingUtilities.invokeLater(new PageLoader(u, c));
    *this class load help files
    class PageLoader implements Runnable {
    *Taa default constructor
    *@param Url the url,Cursor c
    *@return Nothing
    *@thorws nothing
    *@see descon
         PageLoader(URL u, Cursor c) {
         url = u;
         cursor = c;
    public void run() {
         if (url == null) {
              // restore the original cursor
              hh.setCursor(cursor);
              Container parent = hh.getParent();
              parent.repaint();
         } else {
              Document doc = hh.getDocument();
              try {
              hh.setPage(url);
              } catch (IOException ioe) {
              hh.setDocument(doc);
              getToolkit().beep();
              } finally {
              // schedule the cursor to revert after
              // the paint has happended.
              url = null;
              SwingUtilities.invokeLater(this);
         URL url;
         Cursor cursor;

  • Help needed:Printing HTML file using javax.print

    Hi
    I am using the following code which i got form the forum for rpinting an HTML file.
    The folllowing code is working fine, but the problem is the content of HTML file is not getting printed. I am geeting a blank page with no content. What is the change that is required in the code? ALso is there any simpler way to implement this. Help needed ASAP.
    public boolean printHTMLFile(String filename) {
              try {
                   JEditorPane editorPane = new JEditorPane();
                   editorPane.setEditorKit(new HTMLEditorKit());
                   //editorPane.setContentType("text/html");
                   editorPane.setSize(500,500);
                   String text = getFileContents(filename);
                   if (text != null) {
                        editorPane.setText(text);                    
                   } else {
                        return false;
                   printEditorPane(editorPane);
                   return true;
              } catch (Exception tce) {
                   tce.printStackTrace();
              return false;
         public String getFileContents(String filename) {
              try {
                   File file = new File(filename);
                   BufferedReader br = new BufferedReader(new FileReader(file));
                   String line;
                   StringBuffer sb = new StringBuffer();
                   while ((line = br.readLine()) != null) {
                        sb.append(line);
                   br.close();
                   return sb.toString();
              } catch (Exception tce) {
                   tce.printStackTrace();
              return null;
         public void printEditorPane(JEditorPane editorPane) {
                   try {
                        HTMLPrinter htmlPrinter = new HTMLPrinter();
                        htmlPrinter.printJEditorPane(editorPane, htmlPrinter.showPrintDialog());
                   } catch (Exception tce) {
                        tce.printStackTrace();
         * Sets up to easily print HTML documents. It is not necessary to call any of the setter
         * methods as they all have default values, they are provided should you wish to change
         * any of the default values.
         public class HTMLPrinter {
         public int DEFAULT_DPI = 72;
         public float DEFAULT_PAGE_WIDTH_INCH = 8.5f;
         public float DEFAULT_PAGE_HEIGHT_INCH = 11f;
         int x = 100;
         int y = 80;
         GraphicsConfiguration gc;
         PrintService[] services;
         PrintService defaultService;
         DocFlavor flavor;
         PrintRequestAttributeSet attributes;
         Vector pjlListeners = new Vector();
         Vector pjalListeners = new Vector();
         Vector psalListeners = new Vector();
         public HTMLPrinter() {
              gc = null;
              attributes = new HashPrintRequestAttributeSet();
              flavor = null;
              defaultService = PrintServiceLookup.lookupDefaultPrintService();
              services = PrintServiceLookup.lookupPrintServices(flavor, attributes);
              // do something with the supported docflavors
              DocFlavor[] df = defaultService.getSupportedDocFlavors();
              for (int i = 0; i < df.length; i++)
              System.out.println(df.getMimeType() + " " + df[i].getRepresentationClassName());
              // if there is a default service, but no other services
              if (defaultService != null && (services == null || services.length == 0)) {
              services = new PrintService[1];
              services[0] = defaultService;
         * Set the GraphicsConfiguration to display the print dialog on.
         * @param gc a GraphicsConfiguration object
         public void setGraphicsConfiguration(GraphicsConfiguration gc) {
              this.gc = gc;
         public void setServices(PrintService[] services) {
              this.services = services;
         public void setDefaultService(PrintService service) {
              this.defaultService = service;
         public void setDocFlavor(DocFlavor flavor) {
              this.flavor = flavor;
         public void setPrintRequestAttributes(PrintRequestAttributeSet attributes) {
              this.attributes = attributes;
         public void setPrintDialogLocation(int x, int y) {
              this.x = x;
              this.y = y;
         public void addPrintJobListener(PrintJobListener pjl) {
              pjlListeners.addElement(pjl);
         public void removePrintJobListener(PrintJobListener pjl) {
              pjlListeners.removeElement(pjl);
         public void addPrintServiceAttributeListener(PrintServiceAttributeListener psal) {
              psalListeners.addElement(psal);
         public void removePrintServiceAttributeListener(PrintServiceAttributeListener psal) {
              psalListeners.removeElement(psal);
         public boolean printJEditorPane(JEditorPane jep, PrintService ps) {
                   if (ps == null || jep == null) {
                        System.out.println("printJEditorPane: jep or ps is NULL, aborting...");
                        return false;
                   // get the root view of the preview pane
                   View rv = jep.getUI().getRootView(jep);
                   // get the size of the view (hopefully the total size of the page to be printed
                   int x = (int) rv.getPreferredSpan(View.X_AXIS);
                   int y = (int) rv.getPreferredSpan(View.Y_AXIS);
                   // find out if the print has been set to colour mode
                   DocPrintJob dpj = ps.createPrintJob();
                   PrintJobAttributeSet pjas = dpj.getAttributes();
                   // get the DPI and printable area of the page. use default values if not available
                   // use this to get the maximum number of pixels on the vertical axis
                   PrinterResolution pr = (PrinterResolution) pjas.get(PrinterResolution.class);
                   int dpi;
                   float pageX, pageY;
                   if (pr != null)
                        dpi = pr.getFeedResolution(PrinterResolution.DPI);
                   else
                        dpi = DEFAULT_DPI;
                   MediaPrintableArea mpa = (MediaPrintableArea) pjas.get(MediaPrintableArea.class);
                   if (mpa != null) {
                        pageX = mpa.getX(MediaPrintableArea.INCH);
                        pageY = mpa.getX(MediaPrintableArea.INCH);
                   } else {
                        pageX = DEFAULT_PAGE_WIDTH_INCH;
                        pageY = DEFAULT_PAGE_HEIGHT_INCH;
                   int pixelsPerPageY = (int) (dpi * pageY);
                   int pixelsPerPageX = (int) (dpi * pageX);
                   int minY = Math.max(pixelsPerPageY, y);
                   // make colour true if the user has selected colour, and the PrintService can support colour
                   boolean colour = pjas.containsValue(Chromaticity.COLOR);
                   colour = colour & (ps.getAttribute(ColorSupported.class) == ColorSupported.SUPPORTED);
                   // create a BufferedImage to draw on
                   int imgMode;
                   if (colour)
                        imgMode = BufferedImage.TYPE_3BYTE_BGR;
                   else
                        imgMode = BufferedImage.TYPE_BYTE_GRAY;
                   BufferedImage img = new BufferedImage(pixelsPerPageX, minY, imgMode);
                   Graphics myGraphics = img.getGraphics();
                   myGraphics.setClip(0, 0, pixelsPerPageX, minY);
                   myGraphics.setColor(Color.WHITE);
                   myGraphics.fillRect(0, 0, pixelsPerPageX, minY);
                        java.awt.Rectangle rectangle=new java.awt.Rectangle(0,0,pixelsPerPageX, minY);
                   // call rootView.paint( myGraphics, rect ) to paint the whole image on myGraphics
                   rv.paint(myGraphics, rectangle);
                   try {
                        // write the image as a JPEG to the ByteArray so it can be printed
                        Iterator writers = ImageIO.getImageWritersByFormatName("jpeg");
                        ImageWriter writer = (ImageWriter) writers.next();
                                       // mod: Added the iwparam to create the highest quality image possible
                        ImageWriteParam iwparam = writer.getDefaultWriteParam();
                        iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT) ;
                        iwparam.setCompressionQuality(1.0f); // highest quality
                        ByteArrayOutputStream out = new ByteArrayOutputStream();
                        ImageOutputStream ios = ImageIO.createImageOutputStream(out);
                        writer.setOutput(ios);
                        // get the number of pages we need to print this image
                        int imageHeight = img.getHeight();
                        int numberOfPages = (int) Math.ceil(minY / (double) pixelsPerPageY);
                        // print each page
                        for (int i = 0; i < numberOfPages; i++) {
                             int startY = i * pixelsPerPageY;
                             // get a subimage which is exactly the size of one page
                             BufferedImage subImg = img.getSubimage(0, startY, pixelsPerPageX, Math.min(y - startY, pixelsPerPageY));
                                                 // mod: different .write() method to use the iwparam parameter with highest quality compression
                             writer.write(null, new IIOImage(subImg, null, null), iwparam);
                             SimpleDoc sd = new SimpleDoc(out.toByteArray(), DocFlavor.BYTE_ARRAY.JPEG, null);
                             printDocument(sd, ps);
                             // reset the ByteArray so we can start the next page
                             out.reset();
                   } catch (PrintException e) {
                        System.out.println("Error printing document.");
                        e.printStackTrace();
                        return false;
                   } catch (IOException e) {
                        System.out.println("Error creating ImageOutputStream or writing to it.");
                        e.printStackTrace();
                        return false;
                   // uncomment this code and comment out the 'try-catch' block above
                   // to print to a JFrame instead of to the printer
                   /*          JFrame jf = new JFrame();
                             PaintableJPanel jp = new PaintableJPanel();
                             jp.setImage( img );
                             JScrollPane jsp = new JScrollPane( jp );
                             jf.getContentPane().add( jsp );
                             Insets i = jf.getInsets();
                             jf.setBounds( 0, 0, newX, y );
                             jf.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
                             jf.setVisible( true );*/
                   return true;
              * Print the document to the specified PrintService.
              * This method cannot tell if the printing was successful. You must register
              * a PrintJobListener
              * @return false if no PrintService is selected in the dialog, true otherwise
              public boolean printDocument(Doc doc, PrintService ps) throws PrintException {
                   if (ps == null)
                   return false;
                   addAllPrintServiceAttributeListeners(ps);
                   DocPrintJob dpj = ps.createPrintJob();
                   addAllPrintJobListeners(dpj);
                   dpj.print(doc, attributes);
                   return true;
              public PrintService showPrintDialog() {
                   return ServiceUI.printDialog(gc, x, y, services, defaultService, flavor, attributes);
              private void addAllPrintServiceAttributeListeners(PrintService ps) {
                   // add all listeners that are currently added to this object
                   for (int i = 0; i < psalListeners.size(); i++) {
                   PrintServiceAttributeListener p = (PrintServiceAttributeListener) psalListeners.get(i);
                   ps.addPrintServiceAttributeListener(p);
              private void addAllPrintJobListeners(DocPrintJob dpj) {
                   // add all listeners that are currently added to this object
                   for (int i = 0; i < pjlListeners.size(); i++) {
                   PrintJobListener p = (PrintJobListener) pjlListeners.get(i);
                   dpj.addPrintJobListener(p);
              // uncomment this also to print to a JFrame instead of a printer
              /* protected class PaintableJPanel extends JPanel {
                   Image img;
                   protected PaintableJPanel() {
                        super();
                   public void setImage( Image i ) {
                        img = i;
                   public void paint( Graphics g ) {
                        g.drawImage( img, 0, 0, this );
    Thanks
    Ram

    Ram,
    I have had printing problems too a year and a half ago. I used all printing apis of java and I still find that it is something java lacks. Now basically you can try autosense. To check whether your printer is capable of printing the docflavor use this PrintServiceLookup.lookupPrintServices(flavor, aset); . If it lists the printer then he can print the document otherwise he can't. I guess that is why you get the error.
    Regards,
    Kevin

  • How to display HTML file in a region

    I am implementing a portal Application
    in the page group i have 2 regions
    in region1 i have URL item type with URL "http://c:\files\welcome.html"
    How can i set the page such that when the page is browsed the welcome.html
    file will be displayed (browsed)in region2
    regards

    Hi,
    It's quite simple - I will a show a very simple example that will give you an idea :-
    1. Create a simple HTML Page ( I have created Sandeep.html ) & put this HTML code:-
    <HTML>
      <BODY>
         This is my First Test Page. 
    </BODY>
    </HTML>
    2. Copy the file to your $ORACLE_MIDTIER_HOME/Apache/Apache/htdocs
    3. Check if you can access the file :- http://your_server:port/Sandeep.html
        You should see the HTML Page.
    4. Now, login to Portal & create a Page.
    5. Add the HTML Portlet to your Page.
    6. Edit teh HTML Portlet and add this code :-
    <IFRAME SRC="http://your_server:port/Sandeep.html">
    </IFRAME>
    7. That's it ! - the Page Sandeep.html is displayed on the Portal Page itself !
    Regards,
    Sandeep

  • How to display HTML file in forms 6i

    please can any one tell me how i can display normal HTML file in forms 6i
    this HTML file will be called from help menu.
    thanks in advance

    If you're fine with opening html file in a separate browser window, you can use web.show_document.
    But if you have to see html inside Form, one of the solution may be use embeded browser. for detail goto http://forms.pjc.bean.over-blog.com/article-1890238.html

  • Display gif files using servletoutputstream (again)

    Hello,
    I'm trying to display several gifs files in a html file. I extract all the files from an oracle database. I'm trying to use a servletoutputstream, but it does not difference between text and image.
    Process:
    1. Select html file from database
    2. Go through each line of html file to find the links to gif files
    - if gif :
    3. Ask for the gif file detected and select from database
    4. use servletoutputstream to display the file
    - end of if
    -else
    5. display the line of text.
    Is it possible to use a servletoutputstream to display several gifs and text content?
    Is there one other solution to do it correctly?
    Thanks in advance,
    Angela.
    The code I use is:
    private void retrieveFile()
    FileWriter fwHtml=null;
    oracle.sql.BLOB blob=null;
    InputStream in=null;
    ServletOutputStream out=null;
    ResultSet rsGif=null;
    try
    //Extract html file from the database
    String query="SELECT * FROM DBFiles WHERE FILENAME='"+file+"'";
    PreparedStatement ps = connection.prepareStatement (query);
    ResultSet rs=ps.executeQuery();
    rs.next();
    String fileName=rs.getString("FILENAME");
    if (fileName.indexOf("html")!=-1)
    InputStream fis=rs.getAsciiStream(5);
    //I read each line to know where the html file calls the links to the gif files
    BufferedReader reader= new BufferedReader(new InputStreamReader(fis));
    String line;
    String mimeType="";
    try{
    while ((line=reader.readLine()) !=null)
    if((line.indexOf("img src="))!=-1)
    int imgIndex=line.indexOf("img src=");
    int altIndex=line.indexOf(" alt=");
    //I obtain the name of the gif file that I obtain from the database
    String gifFile=line.substring(imgIndex+9,altIndex-1);
    query="SELECT * FROM DBFiles WHERE FILENAME='"+gifFile+"'";
    ps.clearParameters();
    ps = connection.prepareStatement (query);
    rsGif=ps.executeQuery();
    rsGif.next();
    blob=((OracleResultSet)rsGif).getBLOB("GIF");
    String gifName=rsGif.getString("FILENAME");
    mimeType = context.getMimeType(gifName);
    response.setContentType(mimeType);
    out = response.getOutputStream();
    in=blob.getBinaryStream();
    int bufferSize=blob.getBufferSize();
    byte[] buffer = new byte[bufferSize];
    int bytesRead=0;
    int intBuffer=in.read(buffer);
    while ((bytesRead=intBuffer)!= -1)
    out.write(buffer,0,bytesRead);
    in.close;
    else
    byte[] bString =line.getBytes();
    mimeType = context.getMimeType(fileName);
    response.setContentType(mimeType);
    out.write(bString,0,line.length());
    catch (IOException ioe) {
    System.out.println("Unable to open Image file "); ioe.printStackTrace();
    finally {
    if (out != null) {
    out.flush();
    out.close();
    ps.clearParameters();
    connection.commit();
    rsGif.close();
    rs.close();
    ps.close();
    catch (SQLException sqle)
    sqle.printStackTrace();
    catch (Exception e)
    e.printStackTrace();

    Let's put it this way, since I don't have the patience to look at your code. HTML cannot have images embedded in it, it can only have links to images. So you could have a servlet that sends an image, but only a single image and nothing else. I see you have code to set the MIME type of the image, so I don't have to tell you about that.

  • How to read html file using

    Gretting All,
    I have a html file....and also have a frame in which i m adding textarea with scroll pane...then setting the component using setcontentpane ....
    It's working fine....
    But i wanna display my html file in that textarea..
    how do i proceesed?
    regards,
    Tarique
    Marry X-mas

    BufferedFileReader in = new BufferedFileReader( new FileReader(....) );
    textArea.read(in, null);

  • How to mail the html file using javamail????

    hi
    i have captured the output of a jsp page in a html file....
    now i wish to send it in the mail ( *** not as an attachment)
    ie
    i wish the output of the jsp ie the html file to be displayed in
    the message box (ie text area) ..... and then when recieved by the
    receipient it shoud be displayed in the message area....
    is there any way to do this ........

    well as said by my fellow poster googling could have given you quick results.
    Anyways,if you are unable to do so checkout the below code snippet.
    SendMail.java:
    ===========
    import java.io.File;
    import java.io.FileReader;
    import java.io.BufferedReader;
    import java.util.Properties;
    import javax.mail.Session;
    import javax.mail.Message;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;  
    import javax.mail.internet.MimeMessage;
    import javax.activation.*;
    * @Author RaHuL
    * uses SMTP to send Email.
    public class SendMail {
        /** Method used to read contents of html/text/XML file */
        public String readFile(String fileName){
           StringBuffer sb = new StringBuffer();
           BufferedReader input = null;
           try{
               input = new BufferedReader(new FileReader(fileName));
               String str = null;
               while ((str = input.readLine()) != null){    
                      sb.append(line);
           }catch(Exception exp){
               exp.printStackTrace();
           }finally{
                  try {
                        if (input!= null)  
                          input.close(); 
                   }catch (Exception ex) {
                         ex.printStackTrace();
           return sb.toString();
        /** Send an HTML Email with the specific subject to specfic toAddress based on specified fromAddress & Smtp Hostname
          * and returns true on success.
        public boolean sendMail(String toAddress,String fromAddress,String hostName,String subject,String htmlMessage,String contentType) {
           boolean flag = false;    
            try {
                 String to = toAddress;
                 String from = fromAddress;     
                 String host = hostName;
                 // Setting Mail properties
                 Properties props = new Properties();
                 props.put("mail.smtp.host",host);
                 props.put("mail.debug","true");
                 // Getting a New Instance Generated by the API
                 Session session = Session.getInstance(props);
                   NOTE: a Mail Session could be configured and could be got from the Container via JNDI
                         which could be a better practise.
                // Instantiate a message
                Message msg = new MimeMessage(session);
                //Set message attributes
                msg.setFrom(new InternetAddress(from));
                InternetAddress[] address = {new InternetAddress(to)};
                msg.setRecipients(Message.RecipientType.TO, address);
                // Setting Subject Type
                msg.setSubject(subject);
                msg.setSentDate(new Date());
                // Setting Content Type
                msg.setContent(contentType);
                // Set message content
                msg.setText(htmlMessage);
                //Send the message
                Transport.send(msg);
                flag = true;
            }catch (Exception mex) {
             // Prints all nested (chained) exceptions as well
                mex.printStackTrace();
         return flag;
        public static void main(String args[]){
            SendMail sm = new SendMail();
            String htmlMessage = sm.readFile("myHtmlFile.html");
            boolean flag = sm.sendMail("[email protected]","[email protected]","your.smtp.server","EMail SubJect",htmlMessage,"text/html");
            if(flag)
              System.out.println("MAIL SENT SUCCEFULLY");
             else
              System.out.println("MAIL SENDING FAILURE");                          
    }NOTE:
    =====
    Make sure you inculde javamail & java activation libraries.
    Hope that might help :)
    REGARDS,
    RaHuL

  • Call IE to display html file

    Hi folks,
    how to call the IE from standalone application to display a html file?
    any idea or code?
    thank!

    So...to activate a specific browser such IE, one would have to do the following:
    Runtime.getRuntime.exec("\"C:/Program Files/Internet Explorer/IEXPLORE.EXE\" \"file:///C|/PATH/index.htm\"");
    Where the parameter to the Runtime.exec method is simply the command and argument(s) that you would normally have to use at MS-DOS prompt.
    V.V.

Maybe you are looking for

  • HT3986 Mac mini later 2009-- can i install windows 7 -64 bit on it?

    hi there, can i install dual system on mac mini later 2009? windows 7 32bit or 64 bit? thanks

  • Primary key generation

    How do use primary keys generated by database within entity bean?

  • Studio 1 Verses Studio 2?

    I currently run FCP studio 1, ie with FCP 5, and have used it for quite sometime for broadcast productions. It works reliably and solidly. But render times are slow on powerPC chips especially as clients now want more for the same money. Foolishly ne

  • Nokia E71 small Questions

    I've been using my E71 for 6 months but it has left me with a few small questions. 1.) The 2.5 audio port produces awful hissing when paired up with a pair of Sennheiser in-ear headphones (the noise can be heard on the bundled nokia headphones, just

  • Media Cache for multiple computers

    I'm the post production facility manager at a college and we have Mac Pros where the local user's home folder gets wiped upon logout. Students constantly have issues with the media cache and database. They waste so much time re-conforming audio for p