Show HTML formatting in Oracle ADF

Quick Tip- If you have html content stored in database in string and you want to display same html formatting in ADF.

Use escape attribute in outputText’s escape attribute.You can also try outputFormatted also.In outputFormatted there is no escape property.

     <af:outputText value="&lt;h2>&lt;b>Techartifact&lt;/b>&lt;/h2>" id="ot1"
                         escape="false"/>
          <af:outputFormatted value="&lt;h2>&lt;b>Techartifact&lt;/b>&lt;/h2>" id="of1"/>

and output wil be like below

blog

Happy learning with Vinay Kumar in techartifact.

Java send mail in text and html

We posted earlier how send email using java email api.
Here is example of sending email in plain text and html format in same email.

  //get mail session
        Properties props = new Properties();
        props.put("mail.smtp.host", "localhost");
        Session session = session.getDefaultInstance(props);

        // create the messge.
        MimeMessage mimeMessage = new MimeMessage(session);

        MimeMultipart rootMixedMultipart = new MimeMultipart("mixed");
        mimeMessage.setContent(rootMixedMultipart);

        MimeMultipart nestedRelatedMultipart = new MimeMultipart("related");
        MimeBodyPart relatedBodyPart = new MimeBodyPart();
        relatedBodyPart.setContent(nestedRelatedMultipart);
        rootMixedMultipart.addBodyPart(relatedBodyPart);

        MimeMultipart messageBody = new MimeMultipart("alternative");
        MimeBodyPart bodyPart = null;
        for (int i = 0; i < nestedRelatedMultipart.getCount(); i++) {
            BodyPart bp = nestedRelatedMultipart.getBodyPart(i);
            if (bp.getFileName() == null) {
                bodyPart = (MimeBodyPart) bp;
            }
        }
        if (bodyPart == null) {
            MimeBodyPart mimeBodyPart = new MimeBodyPart();
            nestedRelatedMultipart.addBodyPart(mimeBodyPart);
            bodyPart = mimeBodyPart;
        }
        bodyPart.setContent(messageBody, "text/alternative");

        // Create the plain text part of the message.
        MimeBodyPart plainTextPart = new MimeBodyPart();
        plainTextPart.setText("This is plain text message", "UTF-8");
        messageBody.addBodyPart(plainTextPart);

        // Create the HTML text part of the message.
        MimeBodyPart htmlTextPart = new MimeBodyPart();
        htmlTextPart.setContent("<h1>This is plain HTML message", "text/html;charset=UTF-8");
        messageBody.addBodyPart(htmlTextPart);

        mimeMessage.setReplyTo(new InternetAddress[]{new InternetAddress("[email protected]")});
        mimeMessage.setFrom(new InternetAddress("[email protected]"));
        mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]"));
        mimeMessage.setSentDate(new Date());
        mimeMessage.setSubject("Mixed message");
        Transport.send(mimeMessage);