Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6945809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:29:01+00:00 2026-05-27T13:29:01+00:00

I am trying to implement applicationContextAware in my servlet.I have the data from client

  • 0

I am trying to implement applicationContextAware in my servlet.I have the data from client side coming to my servlet.From my servlet I need to pass it to the beans which has getters and setters.I have my DAO s where I have MYSQL operations.

My applicationContext.xml has

<bean id="dataSource" destroy-method="close"
    class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url"
        value="jdbc:mysql://localhost:3306/bazaar_admin_portal" />
    <property name="username" value="usrnm" />
    <property name="password" value="pwd" />
</bean>

<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    <constructor-arg index="0">
        <ref bean="dataSource" />
    </constructor-arg>
</bean>

<bean
    class="org.dao.impl.TestDAOimpl"
    id="TestDAO">
    <property name="jdbcTemplate" ref="jdbcTemplate" />
</bean>

My web.xml contains

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<servlet>
    <description></description>
    <display-name>TestServlet</display-name>
    <servlet-name>TestServlet</servlet-name>
    <servlet-class>com.controllers.TestServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>TestServlet</servlet-name>
    <url-pattern>/Test</url-pattern>
</servlet-mapping>
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

And in my TestServlet under doPost method

     private static ApplicationContext applicationContext = null;

public void setApplicationContext(ApplicationContext ctx)
        throws BeansException {
    applicationContext = ctx;

I have getters and setters class Test.Also interface TestDAO and TestDAOimpl class which implements the interface.

I want to know how do I pass the data from my servlet to the spring side…i.e set the data which will enable the TestDAOimpl to insert into my DB.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:29:01+00:00Added an answer on May 27, 2026 at 1:29 pm

    Are you sure you don’t want to use Spring WebMVC? It will handle your problem automatically.

    Then try this in you POST Method (It’s quite slow, init it lazily):

    applicationContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am trying to implement a generic way for reading sections from a config file.
Trying to implement the decorator pattern in C# from the code in the Head
I am trying implement Unblock me Puzzle. i want to change image position from
Trying to implement NSCopying for the first time, and I have a question about
I am having an issue when trying to create beans from a spring Application
I'm trying implement Data Annotation to my Linq to SQL objects. The .dbml file
Trying to implement what I thought was a simple concept. I have a user
Trying to implement the following structure from c to use NSArray in objective-c: In
Trying to implement AVAudioplayer and get some metering data of the played music, but
trying to implement a multiplayer. Using the sample from Game Center - Sending and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.