Sitemap    
  Home Food Photographs IT Parenting Resources Learning  
JAVA
J2SE
JSP
Servlet
Spring
Adding logging to the application
Get Started 1
Get Started 2
Get Started 3
Get Started 4
Simple file upload using Spring 1
Simple file upload using Spring 2
Simple file upload using Spring 3
Simple file upload using Spring 4
Spring3 And Hibernate 1
Spring3 And Hibernate 2
Spring3 And Hibernate 3
Spring3 And Hibernate 4
Spring3 Getting Started 1
Spring3 Getting Started 2
Spring3 Getting Started 3
Spring3 Getting Started 4
Spring3 Simple file upload 1
Spring3 Simple file upload 2
Spring3 Simple file upload 3
Spring3 Simple file upload 4
Struts2
Get Started 1

You need to know how simple J2EE web application structure is e.g. WEB-INF folder, context, web.xml before proceeding.

SpringWebMVC is MVC2 architecture as name suggests. So there will be a main Spring controller servlet, your application server will need to know about this servlet i.e. entry is needed in web.xml.

Then Controller servlet will need to pass request and response to application web controllers. Views shall have two state when it is loaded first time and second when user submits them.

Spring version used in this tutorial is: Spring-Version: 2.5.6. BTW version can be found in MANIFEST.MF file in Spring.jar.

Steps
1 Create Web application folders and add Spring jars
2 Change application web.xml for main Spring controller
3 Create application-context.xml application controllers [Get Started 2]
4 Create command class or a value object (POJO) to pass your data
5 Create application Controller class [Get Started 3]
6 Run [Get Started 4]

1A: Create web application folder structure
Note: Compiled classes shall go in classes folder

1B: Add following jars /WEB-INF/lib/
aopalliance.jar
aspectjrt.jar
aspectjweaver.jar
cglib-nodep-2.1_3.jar
commons-beanutils-1.8.1.jar
commons-collections-3.2.1.jar
commons-dbcp.jar
commons-digester.jar
commons-fileupload-1.2.1.jar
commons-io-1.4.jar
commons-lang-2.4.jar
commons-logging.jar
commons-net-1.1.0.jar
commons-pool.jar
commons-validator.jar
jstl.jar
log4j-1.2.15.jar
saxpath-1.0.jar
spring-webmvc.jar
spring.jar

2: /WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
  xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  <display-name>SpringApp</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>

  <context-param>
    <description>spring context configuration</description>
    <param-name>contextConfigLocation</param-name>
    <param-value>WEB-INF/springapp-servlet.xml</param-value>
  </context-param>
  <context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>springapp</param-value>
  </context-param>
  <listener>
    <!-- Bootstrap listener to start up Spring's root WebApplicationContext. -->
    <listener-class>
      org.springframework.web.context.ContextLoaderListener
    </listener-class>
  </listener>
  <servlet>
    <display-name>springapp</display-name>
    <servlet-name>springapp</servlet-name>
    <servlet-class>
      org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>springapp</servlet-name>
    <url-pattern>/login</url-pattern>
  </servlet-mapping>
</web-app>

Note: org.springframework.web.servlet.DispatcherServlet is Spring controller servlet and springapp-servlet.xml will contain application controller definitions.
ADD TO DEL.ICIO.US ADD TO DIGG ADD TO FURL ADD TO REDDIT ADD TO STUMBLEUPON ADD TO TECHNORATI FAVORITES ADD TO SQUIDOO ADD TO YAHOO MYWEB ADD TO ASK ADD TO GOOGLE
Post your comments:
Your Name: 
Security check:
Your Comment: 1500 chars
Latest
Wheat Cookies
WheatCookie
Wheat cookies is a healthy snack for your fussy toddler......
Babyfood  2010-Aug-26
Wheat Cookies
WheatCookie
Wheat cookies is a healthy snack for your fussy toddler......
Veg Recipes Baking  2010-Aug-26
Encoding special characters in userinput or on server
Encoding can be done either in Javascript or JAVA encodeURIComponent, escape, java.net.URLEncoder..
Java JSP  2010-Aug-09
Jstl fmt tag i18n formatdate formatcurrency
fmt:setBundle, native2ascii.exe, fmt:message, fmt:setLocale, fmt:formatDate, fmt:formatNumber type=currency..
Java JSP  2010-Aug-05
How to read and write a file
How to read and write a file java.io.BufferedReader,java.io.FileReader, InputStreamReader ...
Java J2SE  2010-Aug-04
jQuery validate form using ajax 2
How to validate/submit form using ajax and jQuery input#, ($.ajax)..
Javascript  2010-Jul-23
jQuery validate form using ajax 1
How to validate/submit form using ajax and jQuery ($.ajax)..
Javascript  2010-Jul-23
Dosa
Dosa batterDosa
Masala dosa is my favourite South Indian dish and I relish it it whenever we go to a South Indian food joint......
Veg Recipes Parathas  2010-Jul-14
Palak Sukka/Spinach Sukka/Palakachi Sukhi Bhaji
Spinach leaves/images/food/vegrecipes/160X120/PALAK METHI SUKHI BHAJI 2 (2).JPG
If you are looking for a palak recipe apart from aloo palak or palak paneer, which quick yet delicious you are at the right place......
Veg Recipes Dry Veg  2010-Jul-13
How to create datasource in RAD Websphere
Create JDBC provider, datasource and JAAS security setup, JDBC connection URLs
Servers Websphere  2010-Jul-08
Get Started 4
Struts2 framework structure, how various components fit together
Java Struts2  2010-Jul-07
How to populate a form when JSP is called first time
This is achieved throught setting bean in request, using frameworks like Struts2, Spring3..
Java JSP  2010-Jul-07
Spring3 And Hibernate 4
Spring3 and Hibernate 3.5.3 working together @Controller, @RequestMapping, @InitBinder, HibernateTransactionManager, LocalSessionFactoryBean, HibernateTemplate
Java Spring  2010-Jul-07
Spring3 And Hibernate 3
Spring3 and Hibernate 3.5.3 working together @Controller, @RequestMapping, @InitBinder, HibernateTransactionManager, LocalSessionFactoryBean, HibernateTemplate
Java Spring  2010-Jul-07
Spring3 And Hibernate 1
Spring3 and Hibernate 3.5.3 working together @Controller, @RequestMapping, @InitBinder, HibernateTransactionManager, LocalSessionFactoryBean, HibernateTemplate
Java Spring  2010-Jul-07
Spring3 And Hibernate 2
Spring3 and Hibernate 3.5.3 working together @Controller, @RequestMapping, @InitBinder, HibernateTransactionManager, LocalSessionFactoryBean, HibernateTemplate
Java Spring  2010-Jul-07