RECENT POSTS
Struts 2 + Spring Integration Example
In this following example we shall see how to integrate Spring and Struts 2 using the struts2-spring-plugin. We integrate Spring with Struts2 to utilize the Spring’s Dependency Injection feature. First add the org.springframework.web.context.ContextLoaderListener to the web.xml file. ** UPDATE: Spring Complete tutorial now available here. ** UPDATE: Struts 2 Complete tutorial now available here. File : web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app...
read moreDifference between Application Server and Web Server in Java
Application server and web server in Java both are used to host Java web application. Though both application server and web server are generic terms, difference between application server and web server is a famous J2EE interview question. On Java J2EE perspective main difference between web server and application server is support of EJB. In order to run EJB or host enterprise Java application (.ear) file you need anapplication server like JBoss, WebLogic, WebSphere or Glassfish, while you can still run...
read moreHow to get android api version programmatically
There is different ways to get that programmatically . First method . The SDK level (integer) the phone is running is available in: android.os.Build.VERSION.SDK_INT; ** UPDATE: Android Complete tutorial now available here. The enum corresponding to this int is in the android.os.Build.VERSION_CODES class. int currentapiVersion = android.os.Build.VERSION.SDK_INT; if (currentapiVersion < = android.os.Build.VERSION_CODES.FROYO) { // Do something for froyo and above versions } else { // do...
read moreInstalling HTC Incredible Android SDK Drivers
In order to debug on your new HTC Incredible smartphone on Windows 7, you need to install USB drivers from Google. Well, it turns out that the phone is too new for Google to have included support for the Incredible in their driver package. Here is how I got it all working though. It may or may not work for you. 1.) Install the Android SDK and download the USB drivers into a folder inside your SDK as Google tells you to do. My drivers ended up in C:\android-sdk-windows\usb_driver 2.) You next need to hack the file android_winusb.inf...
read moreExecuting batch file(.bat) from Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class JavaRunCommand { public static void main(String args[]) { String stream = null; try { Process p = Runtime.getRuntime().exec( "C:\WINDOWS\system32\cmd.exe /c start C:\Batch\test.bat"); BufferedReader stdInput=new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader stdError=new BufferedReader(new InputStreamReader(p.getErrorStream())); // read the output from the command...
read morelog4j.properties example
A tutorial about “log4j.properties” examples that are used in my project, just for sharing. 1. Output to File All logging will be redirected to your specified log file. log4j.properties # Root logger option log4j.rootLogger=INFO, file # Direct log messages to a log...
read moreStruts 2 + Log4j integration example
In this tutorial we will learn about integrate Log4j with Struts 2 framework. Download It – Logger-Without Library files Log4j Appender Create a text file named “log4j.properties“, put it at the root of the project classpath. The log4j.properties or appender file is the Log4j configuration file, it defines how the Log4j logging mechanism work. ** UPDATE: Struts 2 Complete tutorial now available here. In this example, it will log all the logging detail and outputs it to an...
read moreSending email with attachment using JavaMail API
For sending email with attachment, JavaMail API provides some useful classes like BodyPart, MimeBodyPart etc. For sending email using JavaMail Api you need to import 2 jar files: 1.mail.jar 2.activation.jar Download It mail.jar & activation.jar There are total 7 steps for sending attachment with email. They are: 1. Get the session object 2. Compose message 3. Create MimeBodyPart object and set your message text 4. Create new MimeBodyPart object and set DataHandler...
read moreSending Email through Gmail server
This java tutorial is to send email in java using Gmail. The program will use Gmail SMTP server to send mail. For sending email using JavaMail Api you need to import 2 jar files: 1.mail.jar 2.activation.jar Download It mail.jar & activation.jar package com.simplecode.email; import java.util.Properties; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.AddressException; import...
read moreHow to exclude action methods from validation in struts2
My Action class have the following methods, 1.execute 2.populate 3.fetchElement 4.addElement 5.deleteElement ** UPDATE: Struts 2 Complete tutorial now available here. Suppose if we want to apply validation for addElement and deleteElement method alone and not for other method , then Simply list all the methods you don’t want to be run through the validation framework in the excludeMethods parameter. Since we only want addElement and deleteElement validated, list the other 3 as follows: <interceptor-ref...
read more