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 8672585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:14:31+00:00 2026-06-12T19:14:31+00:00

I am working on an existing code that is using one controller to call

  • 0

I am working on an existing code that is using one controller to call a method on the 2nd controller. There are 2 implementations I have seen so far.

1st Implementation

return new Controller().method(request, response);

2nd Implementation

@Autowired
private Controller controller.

return this.controller.method(request, response);

Which is the right implementation, what are the problems if any with either of them.

  • 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-06-12T19:14:32+00:00Added an answer on June 12, 2026 at 7:14 pm

    The mere fact that you need to call a method from another controller reveals a probable design flaw.

    With option 1, you lose everything the Spring DI container brought you: namely, that other controller may be instantiated by Spring with some other dependencies wired into it. If you instantiate it yourself, even if it does work at this moment, because you probably have no @Autowired / @Value dependencies, it will break once you’ll add dependencies on other resource(s). Besides, you already have an instance the container built for you, why create others ?

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

Sidebar

Related Questions

I'm new to StructureMap and have some existing code that I'm working with that
I'm working on some existing c++ code that appears to be written poorly, and
I am working with some existing code and there is a preloader which loads
I have been working on an HTML editor using an editable iframe that allows
I'm working on some existing code. After a few hours, I've boiled this problem
I'm working on modifying some existing code for a payment gateway and I'm not
Currently, I am working on restructuring an existing code base. I'm new to php
I am working on an existing system written using .NET 2.0 remoting to integrate
I am working on an existing ASP.NET MVC app that started small and has
I'm working with an existing EF data model that includes subclassed objects. That works

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.