Solved

Spring, Servlet web project Integration approaches

Posted on 2011-09-08
1
259 Views
Last Modified: 2012-05-12

i was reading about
Spring, Servlet web project Integration approaches
Approach 1:
         Create web project then add spring capablities by making sure applicationContext.xml file is in WEB-INF folder. Then Create servlet program. Configure dao to access the database.Introduce spring container by Creating singleton class of ApplicationContext as it should be started only once as all beans should be available to servlets.

Approach 2:
ServletContext object is created per application as a singleton object.When ServletContext object is created, listeners are invoked.
 configure Spring container which is started when  application is started which depends on your ServletContext listener by Saving instance of ApplicationContext in ServletContext object as attribute
          I would liek to know which approach is better which one we use where, advantages, disadvantages of each one. I was not clear on this concept. thanks in advance
0
Comment
Question by:gudii9
1 Comment
 
LVL 20

Accepted Solution

by:
Amitkumar Panchal earned 500 total points
ID: 36929928
Hi,

Follow the Approach 2. Refer the section 15.2 Common configurations in http://static.springsource.org/spring/docs/2.5.x/reference/web-integration.html

Comments regarding Approach 1:

- you should have this single servlet
- it should be stateless except for the context
- you should have only one instances of this servlet (specifiable in the web.xml)
- you might have integration problems with other parts of the Spring infrastructure or with examples which relies on the application context maintained in a particular place in the servlet context AND that they expect the application context to be of the type org.springframework.web.context.WebApplicationContext
- You need to close the application context in the destroy method of the servlet.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This video teaches viewers about errors in exception handling.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now