Posts

Showing posts from July, 2008

-- Read a Property File --

--------------------- ERA.properties -------------------- webapp.name=ERA Admin DashBoard webapp.version=Version: neo_jsf_ice_with_tree_06 author.name=Jayasanka Illangarathne author.url=http://jayasanka.blogspot.com company.name=Virtusa Private Ltd: company.url=http://www.virtusa.com copyright.year=2008 dataBase.name=EraDB server.path=jdbc:sqlserver://localhost:1433 dataBase.uname=sa dataBase.passwd=jayasanka -------------------------java file------------------- package com.resource; import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.Properties; public class ERAProperties { public static void main(String[] args) { Properties properties = new Properties(); try { // load the resource file properties.load(new FileInputStream("src/com/resource/ERA.properties")); // get a property String name = properties.getProperty("author.name"); System.out.println...

-- Spring Framework --

Image
-> backGround - Spring is an open-source framework, created by Rod Johnson and described in his book Expert One-on-One: J2EE Design and Development. - Spring is a lightweight inversion of control and aspect-oriented container framework. -> Spring is a development style like J2EE EJB.But solve some limitations of EJB -> problem: in EJB, has to write several classes to make a component. such as the home interface,the local interface,and the bean itself. in addition has to create a deployment descriptor for the bean. -> solution: incorporates XDoclet XDoclet is a code generation tool that can generate all of the necessary EJB files from a single source file. -> Problem: when testing, have to fire up the container in each test and each change of the code. It is a waisting time, the development lifecycle will add a "waitting" phase. (code -> wait -> test). ...

-- Send Mails --

To implement the mail function u must download the javaMail.jar file, and include it to ur lib folder. package com.neo.mail; import java.util.Properties; import javax.mail.*; import javax.mail.internet.*; public class AdminMail { public void postMail( String recipients[ ], String subject, String message , String from) throws MessagingException { boolean debug = false; //Set the host smtp address Properties props = new Properties(); props.put("mail.smtp.host", "mailsvr"); // create some properties and get the default Session Session session = Session.getDefaultInstance(props, null); session.setDebug(debug); // create a message Message msg = new MimeMessage(session); // set the from and to address InternetAddress addressFrom = new InternetAddress(from); msg.setFrom(addressFrom); InternetAddress[] addressTo = new InternetAddress[recipients.length]; for (int i = 0;...