Posts

Spring MVC tutorial

Before Starting, I believe you must have basic idea about JAVA, SPRING and Spring MVC. For Spring MVC : http://waheedtechblog.blogspot.in/2012/08/spring-mvc.html In this tutorial , I will just tell you what are the basic thing that you need to start MVC. Step 1 : Create a class  @Controller public class HelloWorld {        @RequestMapping ( "/hello" )      public String helloWorld() {           return = "Hello World, Spring 3.0!" ;      } } 1 . The class HelloWorld  has the annotation @Controller and @RequestMapping("/hello") . When Spring scans this class, it will recognize this bean as being a Controller bean for processing requests. 2 .The @RequestMapping annotation tells Spring that this Controller should process all requests beginning with /hello in the URL path. Step 2. Mapping Spring MVC in WEB.xml The entry point of Spring 3...

Spring MVC

Image
Spring MVC helps in building flexible and loosely coupled web applications. The Model-view-controller design pattern helps in seperating the business logic, presentation logic and navigation logic. Models are responsible for encapsulating the application data. The Views render response to the user with the help of the model object . Controllers are responsible for receiving the request from the user and calling the back-end services. When a request is sent to the Spring MVC Framework the following sequence of events happen. The DispatcherServlet first receives the request. The DispatcherServlet consults the HandlerMapping and invokes the Controller associated with the request. The Controller process the request by calling the appropriate service methods and returns a ModeAndView object to the DispatcherServlet . The ModeAndView object contains the model data and the view name. ...

Sending Email Via JavaMail API Example

From last one month, My internet device is missing from my terrace. So, Mostly I use mobile to access my mail but accessing mail via mobile is very irritating thing because of the slow bandwidth. To send one single mail I have to wait till the mailbox get opened. This is very simple way to send mail without opening your account. :) This is the example to show you how to use JavaMail API method to send an email via Gmail SMTP server. You need mail.jar library to run this code. import java.util.Properties; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; /**  * @author abdul  *  */ public class SendEmail {     public static void main(String[] args) {                 final String username="YOUR_USER_NAME"...

Spring Auto-Wiring Beans with @Autowired annotation

In Spring, you can use @Autowired annotation to auto wire bean on the setter method, constructor or a field. There are two ways to can achieve it : 1.Using <context:annotation-config />     Just Add Spring context and <context:annotation-config /> in bean configuration file <beans xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"     xmlns:tx="http://www.springframework.org/schema/tx"     xmlns:context="http://www.springframework.org/schema/context"     xsi:schemaLocation="http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/aop     http://www.springframework.org/schema/aop/spring-aop.xsd     http://www.springframework.org/sche...

Error:No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

To solve this problem. You have to do two things: 1. mark the DAO as transactional or function which is doing database call like:   @Transactional    public class EmployeeDaoImpl  extends DaoImpl implements EmployeeDao{  ///// }            OR @Transactional     public long addEmployee(Employee employee) {         System.out.println("Employee:"+employee );         long id = employeeDao.addEmployee(employee);         System.out.println("Id1: " );         return id;     } 2. Enable the annotation driven transcation management in applicationContext.xml (where your beans are defined): <beans xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="ht...

Keyboard Shortcuts That Work in All Web Browsers

Tabs Ctrl+1-8 – Switch to the specified tab, counting from the left. Ctrl+9 – Switch to the last tab. Ctrl+Tab – Switch to the next tab – in other words, the tab on the right. ( Ctrl+Page Up also works, but not in Internet Explorer.) Ctrl+Shift+Tab – Switch to the previous tab – in other words, the tab on the left. ( Ctrl+Page Down also works, but not in Internet Explorer.) Ctrl+W , Ctrl+F4 – Close the current tab. Ctrl+Shift+T – Reopen the last closed tab. Ctrl+T – Open a new tab. Ctrl+N – Open a new browser window. Alt+F4 – Close the current window. (Works in all applications.) Mouse Actions for Tabs Middle Click a Tab – Close the tab. Ctrl+Left Click, Middle Click – Open a link in a background tab. Shift+Left Click – Open a link in a new browser window. Ctrl+Shift+Left Click – Open a link in a foreground tab. Navigation Alt+Left Arrow, Backspace – Back. Alt+Right Arrow, Shift+Backspace – Forward. F5 – Reload. Ctrl+F5 – Reload and...

Use mySQl setup from your virtual machine

Image
Have you ever faced a situation where you want to use your MYSQl from your virtual machine. i,e your MYSQL set up is on the windows and your linux is on VM player and you want to use it rather than installing it again on linux box. If yes, Then here is the solution. My System configuration where I have tested. OS : Windows 7 MYSQL: version 5.5 on windows RHEL 5 on VM player Step: 1 . Open MYSQL workbench 5 2.  Open your MYSQL from server Administrator. 3.  Goto Security -> Users and Privileges 4.  Replace 'localhost' with '%' in limited connectivity to host matching box. And you are done here..:) All credit goes to my Manager..Thanx a lot..:)