<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7218532744083441923</id><updated>2012-02-16T03:08:37.778-08:00</updated><title type='text'>Wrong Experiences, May be not!</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://debasisroy144.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://debasisroy144.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Debasis Roy</name><uri>http://www.blogger.com/profile/09434542057800232471</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp2.blogger.com/_iOkjIjw-aPc/SH88eLWN2tI/AAAAAAAAABY/OSWhFuua-G0/S220/me.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7218532744083441923.post-7475672456836120370</id><published>2010-03-23T20:33:00.000-07:00</published><updated>2010-03-23T20:34:47.706-07:00</updated><title type='text'>Java theory and practice: Generics gotchas</title><content type='html'>&lt;a href="http://www.ibm.com/developerworks/java/library/j-jtp01255.html"&gt;http://www.ibm.com/developerworks/java/library/j-jtp01255.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7218532744083441923-7475672456836120370?l=debasisroy144.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://debasisroy144.blogspot.com/feeds/7475672456836120370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7218532744083441923&amp;postID=7475672456836120370' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/7475672456836120370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/7475672456836120370'/><link rel='alternate' type='text/html' href='http://debasisroy144.blogspot.com/2010/03/java-theory-and-practice-generics.html' title='Java theory and practice: Generics gotchas'/><author><name>Debasis Roy</name><uri>http://www.blogger.com/profile/09434542057800232471</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp2.blogger.com/_iOkjIjw-aPc/SH88eLWN2tI/AAAAAAAAABY/OSWhFuua-G0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7218532744083441923.post-4564683777860928947</id><published>2009-04-04T22:11:00.000-07:00</published><updated>2009-04-05T01:07:46.585-07:00</updated><title type='text'>How to use SINGLETON pattern in a application to access Database?</title><content type='html'>This is sample code for accessing database by applying Singleton design pattern which is also thread safe because of eager initialization.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;/*&lt;/div&gt;&lt;div&gt;Java class code for the above purpose.&lt;/div&gt;&lt;div&gt;*/&lt;/div&gt;&lt;div&gt;&lt;div&gt;import java.sql.Connection;&lt;/div&gt;&lt;div&gt;import java.sql.DriverManager;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;public class DBConf {&lt;/div&gt;&lt;div&gt;    private static Connection connection;&lt;/div&gt;&lt;div&gt;       &lt;br /&gt;&lt;/div&gt;&lt;div&gt;    static{&lt;/div&gt;&lt;div&gt;        try{&lt;/div&gt;&lt;div&gt;            String dbUrl = "&lt;dbhostname&gt;&lt;dbport&gt;&lt;dbname&gt;jdbc:mysql://dbhost:dbport/dbname";&lt;/dbname&gt;&lt;/dbport&gt;&lt;/dbhostname&gt;&lt;/div&gt;&lt;div&gt;            String dbUname = "dbusername&lt;dbusername&gt;";&lt;/dbusername&gt;&lt;/div&gt;&lt;div&gt;            String dbPword = "dbpassword&lt;dbpassword&gt;";&lt;/dbpassword&gt;&lt;/div&gt;&lt;div&gt;            &lt;/div&gt;&lt;div&gt;            Class.forName("com.mysql.jdbc.Driver");&lt;/div&gt;&lt;div&gt;            connection = DriverManager.getConnection(dbUrl, dbUname, dbPword);&lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;        catch(Exception ex){&lt;/div&gt;&lt;div&gt;            ex.printStackTrace();&lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    private DBConf(){}&lt;/div&gt;&lt;div&gt;    &lt;/div&gt;&lt;div&gt;    public static Connection getConnection(){&lt;/div&gt;&lt;div&gt;        return DBConf.connection;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Look at the constructor which is defined as private so no one can instantiate it. The client can use the getConnection() method to get the Connection which is already eagerly loaded. This single connection can be used to access the Database by the whole application by not openning new connections.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now a question comes, when to close the connection. My solution is just add a listener class to this application. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;/*&lt;/div&gt;&lt;div&gt;Add this code to your web.xml file. Please replace ]&lt;span class="Apple-style-span" style="font-weight: bold;"&gt; with &gt; and [ with &lt;&lt;/span&gt; in the following code.&lt;/div&gt;&lt;div&gt;*/&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;listener&gt;&lt;/listener&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 102, 102);"&gt;[listener]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;        &lt;span class="Apple-style-span" style="color: rgb(255, 102, 102);"&gt;[&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 102, 102);"&gt;listener-class]&lt;/span&gt;ApplicationWatch&lt;span class="Apple-style-span" style="color: rgb(255, 102, 102);"&gt;[/listener-class]&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 102, 102);"&gt;[/listener]&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;/*&lt;/div&gt;&lt;div&gt;Write the following class in your application default source directory.&lt;/div&gt;&lt;div&gt;*/&lt;/div&gt;&lt;div&gt;&lt;div&gt;import javax.servlet.ServletContextListener;&lt;/div&gt;&lt;div&gt;import javax.servlet.ServletContextEvent;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;public class ApplicationWatch implements ServletContextListener&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;{&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;/* Application Startup Event */&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;public void contextInitialized(ServletContextEvent ce) {}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;/* Application Shutdown&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;Event */&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;public void contextDestroyed(ServletContextEvent ce) {&lt;/div&gt;&lt;div&gt;            try{&lt;/div&gt;&lt;div&gt;                DBConf.getConnection().close();&lt;/div&gt;&lt;div&gt;            }&lt;/div&gt;&lt;div&gt;            catch(Exception ex){&lt;/div&gt;&lt;div&gt;                ex.printStackTrace();&lt;/div&gt;&lt;div&gt;            }&lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, when the application will be destroyed (i.e. undeploying the application from the server) the connection will be closed.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;Problems&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;1. This connection should be alive for the application lifetime. But the real scenario is, Database like MySQL shutdown the idle connection when it reaches its wait timeout, default is 8 hours.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;But for, heavy hitted application for database connection, connection pooling is a better solution. Hope I will write about it in future.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Wish this article will help you. Thanks.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7218532744083441923-4564683777860928947?l=debasisroy144.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://debasisroy144.blogspot.com/feeds/4564683777860928947/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7218532744083441923&amp;postID=4564683777860928947' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/4564683777860928947'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/4564683777860928947'/><link rel='alternate' type='text/html' href='http://debasisroy144.blogspot.com/2009/04/how-to-use-singleton-pattern-in.html' title='How to use SINGLETON pattern in a application to access Database?'/><author><name>Debasis Roy</name><uri>http://www.blogger.com/profile/09434542057800232471</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp2.blogger.com/_iOkjIjw-aPc/SH88eLWN2tI/AAAAAAAAABY/OSWhFuua-G0/S220/me.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7218532744083441923.post-35035429909488539</id><published>2009-03-29T21:19:00.000-07:00</published><updated>2009-03-29T21:29:31.504-07:00</updated><title type='text'>Hibernate Exception - java.net.SocketException: Broken pipe</title><content type='html'>In my current project I am using Hibernate ORM model for java to mysql bridge. And after deploying the module in a test sever I got the exception "java.net.SocketException: Broken pipe".&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I have found the possible reasons may be, &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1. I didn't set the connection timeout parameters for the connection pool&lt;/div&gt;&lt;div&gt;2. The main scenario is, hibernate connection pool keeps the opened connection for a long time and mysql closes it when its idle time reaches for the opened connection.&lt;/div&gt;&lt;div&gt;3. When hibernate trys to do something with this connection which is closed by mysql got the exception.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Possible solution is, try to define the idle timeout value for the connection in hibernate lower than the mysql system connection idle timeout. This is very easy in hibernate.cfg.xml file to define the connection pool parameters and a lot of web resources can be found by google how to do it. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Thanks. Hope it will help you.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7218532744083441923-35035429909488539?l=debasisroy144.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://debasisroy144.blogspot.com/feeds/35035429909488539/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7218532744083441923&amp;postID=35035429909488539' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/35035429909488539'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/35035429909488539'/><link rel='alternate' type='text/html' href='http://debasisroy144.blogspot.com/2009/03/hibernate-exception-javanetsocketexcept.html' title='Hibernate Exception - java.net.SocketException: Broken pipe'/><author><name>Debasis Roy</name><uri>http://www.blogger.com/profile/09434542057800232471</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp2.blogger.com/_iOkjIjw-aPc/SH88eLWN2tI/AAAAAAAAABY/OSWhFuua-G0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7218532744083441923.post-8181523230641791145</id><published>2008-09-16T05:37:00.000-07:00</published><updated>2008-09-16T05:48:56.936-07:00</updated><title type='text'>MySQL Scheduled Events</title><content type='html'>At the time of my undergraduate study, I had to implement a database project. In that project I had to implement a module almost like the working style of trigger just on the event of some specific time and interval. At that time I designed that module by implementing an outside program which runs as a process and at specific time it fires and manipulates some database tables.&lt;br /&gt;&lt;br /&gt;But , today I have learned a new feature of mysql which is called Scheduled Events which runs a batch of sqls on a specific time or intervals. See the following link, how to create  a scheduled event in mysql 5.1 or later version. Hope it is useful to all developers.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://dev.mysql.com/tech-resources/articles/mysql-events.html#1"&gt;http://dev.mysql.com/tech-resources/articles/mysql-events.html#1&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7218532744083441923-8181523230641791145?l=debasisroy144.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://debasisroy144.blogspot.com/feeds/8181523230641791145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7218532744083441923&amp;postID=8181523230641791145' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/8181523230641791145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/8181523230641791145'/><link rel='alternate' type='text/html' href='http://debasisroy144.blogspot.com/2008/09/mysql-scheduled-events.html' title='MySQL Scheduled Events'/><author><name>Debasis Roy</name><uri>http://www.blogger.com/profile/09434542057800232471</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp2.blogger.com/_iOkjIjw-aPc/SH88eLWN2tI/AAAAAAAAABY/OSWhFuua-G0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7218532744083441923.post-9017672516463965806</id><published>2008-07-21T06:30:00.000-07:00</published><updated>2008-07-21T06:57:12.249-07:00</updated><title type='text'>Reading a txt file Content from URL by JavaScript</title><content type='html'>The &lt;span style="font-weight: bold; font-style: italic;"&gt;html&lt;/span&gt; file having this script should be in the same domain with &lt;span style="font-weight: bold; font-style: italic;"&gt;txt&lt;/span&gt; file for accessing from &lt;span style="font-weight: bold;"&gt;mozilla firefox&lt;/span&gt; because of security reason. From&lt;span style="font-weight: bold;"&gt; internet explorer&lt;/span&gt; &lt;span style="font-weight: bold; font-style: italic;"&gt;txt&lt;/span&gt; file from any url can be read.&lt;br /&gt;&lt;br /&gt;var xmlhttp;&lt;br /&gt;function getFile(pURL) {   &lt;br /&gt;if (window.XMLHttpRequest) {&lt;br /&gt; xmlhttp = new XMLHttpRequest();&lt;br /&gt;}&lt;br /&gt;else if (window.ActiveXObject) {&lt;br /&gt; xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");&lt;br /&gt;}&lt;br /&gt;xmlhttp.open("GET",pURL,true);&lt;br /&gt;xmlhttp.onreadystatechange = showFileContent;&lt;br /&gt;xmlhttp.send(null);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function showFileContent() {&lt;br /&gt;if (xmlhttp.readyState==4) {&lt;br /&gt; if (xmlhttp.status==200) {&lt;br /&gt;     var out=xmlhttp.responseText;    &lt;br /&gt;     document.getElementById('theExample').innerHTML=out;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;See my codes, 1 having this script and reads contents from 2.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;a href="http://debasisroy144.googlepages.com/helloworld.html"&gt;http://debasisroy144.googlepages.com/helloworld.html&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://debasisroy144.googlepages.com/helloworld.txt"&gt;http://debasisroy144.googlepages.com/helloworld.txt&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7218532744083441923-9017672516463965806?l=debasisroy144.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://debasisroy144.blogspot.com/feeds/9017672516463965806/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7218532744083441923&amp;postID=9017672516463965806' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/9017672516463965806'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/9017672516463965806'/><link rel='alternate' type='text/html' href='http://debasisroy144.blogspot.com/2008/07/reading-txt-file-content-from-url-by.html' title='Reading a txt file Content from URL by JavaScript'/><author><name>Debasis Roy</name><uri>http://www.blogger.com/profile/09434542057800232471</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp2.blogger.com/_iOkjIjw-aPc/SH88eLWN2tI/AAAAAAAAABY/OSWhFuua-G0/S220/me.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7218532744083441923.post-1224649230887249920</id><published>2008-07-18T23:14:00.000-07:00</published><updated>2008-07-19T00:28:13.286-07:00</updated><title type='text'>Sending mail with attachment by JAVA</title><content type='html'>For this class mail-1.4.jar file will be needed as a library which can be found in this following site&lt;br /&gt;&lt;a href="http://www.java2s.com/Code/Jar/wsit/Downloadmail14jar.htm"&gt;http://www.java2s.com/Code/Jar/wsit/Downloadmail14jar.htm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;import java.util.Properties;&lt;br /&gt;import javax.mail.*;&lt;br /&gt;import javax.mail.internet.*;&lt;br /&gt;import javax.activation.*;&lt;br /&gt;&lt;br /&gt;public class SendEmail { &lt;br /&gt;&lt;br /&gt;   public SendEmail() {&lt;br /&gt;   }  &lt;br /&gt;   public static void sendEmail(String host, String from, String to, String subject, String     infoMessage) throws Exception {&lt;br /&gt;       sendEmailWithAttachment(host, from, to, subject, infoMessage, "n/a");&lt;br /&gt;   }&lt;br /&gt;   public static void sendEmailWithAttachment(String host, String from, String to, String subject, String infoMessage, String fileAttachment) throws Exception {&lt;br /&gt;     &lt;br /&gt;       // Get system properties&lt;br /&gt;       Properties props = System.getProperties();&lt;br /&gt;     &lt;br /&gt;       // Setup mail server&lt;br /&gt;       props.put("mail.smtp.host", host);&lt;br /&gt;     &lt;br /&gt;       // Get session&lt;br /&gt;       Session session = Session.getInstance(props, null);&lt;br /&gt;     &lt;br /&gt;       // Define message&lt;br /&gt;       MimeMessage message = new MimeMessage(session);&lt;br /&gt;       message.setFrom(new InternetAddress(from));&lt;br /&gt;       message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));&lt;br /&gt;       message.setSubject(subject);&lt;br /&gt;     &lt;br /&gt;       // create the message part&lt;br /&gt;       MimeBodyPart messageBodyPart = new MimeBodyPart();&lt;br /&gt;     &lt;br /&gt;       //fill message&lt;br /&gt;       messageBodyPart.setText(infoMessage);&lt;br /&gt;     &lt;br /&gt;       Multipart multipart = new MimeMultipart();&lt;br /&gt;       multipart.addBodyPart(messageBodyPart);&lt;br /&gt;     &lt;br /&gt;       // Part two is attachment&lt;br /&gt;       if(!fileAttachment.equals("n/a")){&lt;br /&gt;           messageBodyPart = new MimeBodyPart();&lt;br /&gt;           DataSource source = new FileDataSource(fileAttachment);&lt;br /&gt;           messageBodyPart.setDataHandler(new DataHandler(source));&lt;br /&gt;           messageBodyPart.setFileName("MarbilReport.pdf");&lt;br /&gt;           multipart.addBodyPart(messageBodyPart);&lt;br /&gt;       }&lt;br /&gt;     &lt;br /&gt;       // Put parts in message&lt;br /&gt;       message.setContent(multipart);&lt;br /&gt;     &lt;br /&gt;       // Send the message&lt;br /&gt;       Transport.send( message );&lt;br /&gt;   }  &lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7218532744083441923-1224649230887249920?l=debasisroy144.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://debasisroy144.blogspot.com/feeds/1224649230887249920/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7218532744083441923&amp;postID=1224649230887249920' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/1224649230887249920'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/1224649230887249920'/><link rel='alternate' type='text/html' href='http://debasisroy144.blogspot.com/2008/07/sending-mail-with-attachment-by-java.html' title='Sending mail with attachment by JAVA'/><author><name>Debasis Roy</name><uri>http://www.blogger.com/profile/09434542057800232471</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp2.blogger.com/_iOkjIjw-aPc/SH88eLWN2tI/AAAAAAAAABY/OSWhFuua-G0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7218532744083441923.post-5251368434605286780</id><published>2008-07-17T00:15:00.000-07:00</published><updated>2008-07-17T00:36:04.390-07:00</updated><title type='text'>Configuring Tomcat Server for JAX-WS Support</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Step 1 – Install JAX-WS&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Go to &lt;a href="https://jax-ws.dev.java.net/2.1.3/"&gt;https://jax-ws.dev.java.net/2.1.3/&lt;/a&gt; and click on the link to download the binary. Double click on the downloaded binary and this will extract the contents into a sub-folder &lt;span style="font-style: italic;"&gt;jaxws-ri&lt;/span&gt;. If you look in &lt;span style="font-style: italic;"&gt;jaxws-ri\lib&lt;/span&gt; you will see all the jars that we need for deploying to Tomcat&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 2 – Copy JAX-WS jars to Tomcat&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Copy all the jars from jaxws-ri\lib to Tomcat lib directory. Tomcat will now support WebServices.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 3 – Include the JAX-WS Jars in the Project Path to compile Web Services and Web Service clients&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Just add the jar file jaxws-tools.jar  can be found in the extracted folder jaxws-ri\lib.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;For more details please visit this site, &lt;a href="http://life-on-a-laptop.blogspot.com/"&gt;http://life-on-a-laptop.blogspot.com/&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7218532744083441923-5251368434605286780?l=debasisroy144.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://debasisroy144.blogspot.com/feeds/5251368434605286780/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7218532744083441923&amp;postID=5251368434605286780' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/5251368434605286780'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/5251368434605286780'/><link rel='alternate' type='text/html' href='http://debasisroy144.blogspot.com/2008/07/configuring-tomcat-server-for-jax-ws.html' title='Configuring Tomcat Server for JAX-WS Support'/><author><name>Debasis Roy</name><uri>http://www.blogger.com/profile/09434542057800232471</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp2.blogger.com/_iOkjIjw-aPc/SH88eLWN2tI/AAAAAAAAABY/OSWhFuua-G0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7218532744083441923.post-4129182110317390225</id><published>2008-07-17T00:13:00.001-07:00</published><updated>2008-07-17T00:36:52.000-07:00</updated><title type='text'>Dynamic Invoking of Web Service Methods</title><content type='html'>&lt;div style="text-align: justify;"&gt;When creating a JAX-WS client a Class like the following is created,&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;public class ServiceName extends Service {&lt;br /&gt;  private final static URL SERVICENAME_WSDL_LOCATION;&lt;br /&gt;  static {&lt;br /&gt;      URL url = null;&lt;br /&gt;      try {&lt;br /&gt;          url = new URL("http://IP:PORT/CONTEXTPATH/ServiceName?WSDL");&lt;br /&gt;      } catch (MalformedURLException e) {&lt;br /&gt;          e.printStackTrace();&lt;br /&gt;      }&lt;br /&gt;      SERVICENAME_WSDL_LOCATION = url;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public ServiceName(URL wsdlLocation, QName serviceName) {&lt;br /&gt;      super(wsdlLocation, serviceName);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public ServiceName() {&lt;br /&gt;      super(SERVICENAME_WSDL_LOCATION, new QName("http://PACKAGENAME/", "SERVICENAME"));&lt;br /&gt;  }&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Anyone can see this class in netbeans from file section going through build-&gt;generated-&gt;wsimport-&gt;client and then under the given package name. Naturally, when we create an instance of this service using IDE generated code, what happens is IDE puts the second constructor for it,&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;ServiceName service = new ServiceName();&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;which takes the static wsdl url. And now look at the first constructor, if we create service instance by using first constructor in our code then, wsdlLocation and serviceName parameters can be drawn from a configuration xml file. So, if we have done this in our project then if sevice wsdl location changed then we don't have to recompile the project by creating new JAX-WS client with providing the new wsdl location. We just have to change the wsdl url location in the configuration file. And getting the port from service then we can access the methods under that web service.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7218532744083441923-4129182110317390225?l=debasisroy144.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://debasisroy144.blogspot.com/feeds/4129182110317390225/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7218532744083441923&amp;postID=4129182110317390225' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/4129182110317390225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/4129182110317390225'/><link rel='alternate' type='text/html' href='http://debasisroy144.blogspot.com/2008/07/dynamic-invoking-of-web-service-methods.html' title='Dynamic Invoking of Web Service Methods'/><author><name>Debasis Roy</name><uri>http://www.blogger.com/profile/09434542057800232471</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp2.blogger.com/_iOkjIjw-aPc/SH88eLWN2tI/AAAAAAAAABY/OSWhFuua-G0/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7218532744083441923.post-2965473326569487257</id><published>2008-06-15T20:58:00.000-07:00</published><updated>2008-07-17T00:37:45.400-07:00</updated><title type='text'>Netbeans Visual Web Pack</title><content type='html'>&lt;div style="text-align: justify;"&gt;This is a web based application development tool with a visual editor for developing user interfaces.&lt;br /&gt;&lt;br /&gt;I have used netbeans-5.5.1 and netbeans-visualweb-5.5.1 together in windows and have a great pleasure in developing web user interfaces. I have used jasper reporting with it also. And it seems pretty stable to me for sun java application server.&lt;br /&gt;&lt;br /&gt;Currently, I am working on netbeans-6.1 and Tomcat Server-6.0.16.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7218532744083441923-2965473326569487257?l=debasisroy144.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://debasisroy144.blogspot.com/feeds/2965473326569487257/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=7218532744083441923&amp;postID=2965473326569487257' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/2965473326569487257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7218532744083441923/posts/default/2965473326569487257'/><link rel='alternate' type='text/html' href='http://debasisroy144.blogspot.com/2008/06/netbeans-visual-web-pack.html' title='Netbeans Visual Web Pack'/><author><name>Debasis Roy</name><uri>http://www.blogger.com/profile/09434542057800232471</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp2.blogger.com/_iOkjIjw-aPc/SH88eLWN2tI/AAAAAAAAABY/OSWhFuua-G0/S220/me.jpg'/></author><thr:total>0</thr:total></entry></feed>
