?
Solved

Spring, Servlet web project Integration approaches

Posted on 2011-09-08
1
Medium Priority
?
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 21

Accepted Solution

by:
Amitkumar Panchal earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
A solution for Fortify Path Manipulation.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

770 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