Posts

Showing posts from October, 2016

How to send Mail in Java

package com.sendMail; import java.io.FileInputStream; import java.util.Properties; import javax.mail.Address; import javax.mail.BodyPart; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.Multipart; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMultipart; /**  *  * @author ananddw  *  */ public class EmailService { public boolean  SendMail(String voucherID){        boolean flag=false;     Properties props = System.getProperties();     props.put("mail.smtp.host", " smtp.gmail.com "); //SMTP Host     props.put("mail.smtp.port", "587"); //TLS Port     props.put("mail.smtp.auth", "true"); //enable aut...

Action Message and Action Error in Struts2

Image
Find below code to check how action Error and Action Message is working in Struts2 ####login.jsp <%--     Document   : login     Created on : Oct 09, 2016, 2:50:34 PM     Author     : shiboo --%> <!DOCTYPE html> <%@taglib uri="/struts-tags" prefix="s"%> <html> <head> <title>Login</title> </head> <body> <center><h3>ActionMessage Example</h3> <s:actionerror /> <s:form action="login"> <s:textfield name="userName"  label="Username" /> <s:password name="password"  label="password" /> <s:submit value="Login" /> </s:form> </center> </body> </html> ####success.jsp <%--     Document   : success     Created on : Oct 09, 2016, 2:41:34 PM     Author     : shiboo --%> <%@ taglib prefix="s" uri="/struts-tags"%> ...

Hibernate Application Java

Hibernate framework simplifies the development of java application to interact with the database. Hibernate is an open source, lightweight  tool.  An ORM tool simplifies the data creation, data manipulation and data access. It is a programming technique that maps the object to the data stored in the database. Example Student.java package com.hibernate; /**  *  * @author ananddw  *  */ public class Student {         private int id;     private String studentName;     private String studentPlace;         //Setter and Getters         public int getId() {         return id;     }     public void setId(int id) {         this.id = id;     }     public String getStudentName() {   ...

Reverse String in Java

How to reverse String in Java without using external function . here is the easiest way to reverse String in java public class ReverseString{     public static void main(String []args){         String value="Anand";         for(int i=value.length()-1;i>=0;i--){             System.out.println(value.charAt(i));                     }     } }