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

  • Home
  • SEARCH
  • 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 8912333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:10:18+00:00 2026-06-15T04:10:18+00:00

I have a spring controller method. It’s meant to programmatically sign up user (through

  • 0

I have a spring controller method. It’s meant to programmatically sign up user (through a single sign on process from another system within the product). It works by getting user data, validating it, creating a user account if it doesnot exist, communicate back to the other system a shared token, and then authenticating the user. There is a handshake process going on, but to get to to the bottom of the problem. I want the same method to return a string if the user is not existing in the system, and return a ModelAndView if they are already registered.

Possible solutions (but cannot execute them):

  • The returned string (in the case of the first time user) is going to be read using an HttpURLConnection input stream. So if there is a way to put data in ModelAndView object, and then read it using the input stream, then I am set.
  • I can return the string and read it OK using the input stream by making the return type as @ResponseBody String, however, I cannot return a view when it is an existing user.

Ideally, I would return a model and view, but the other system is not spring, and so it won’t understand it.

To summarize, one method that does two things, if the user the a first time user, it returns a string to another system with an encryption token, which the other system will use in an iframe to authenticate the user.

Need to return a string in one case to be read using an input stream reader in another system, and in the case of an existing user, a view needs to be returned to be read using spring itself.

Please let me know if any of this isnot clear.

EDIT: Is there a way to return an http response (something like http servlet response) that is generic enough and works inside and outside of spring. This will also solve my problem.

  • 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-15T04:10:20+00:00Added an answer on June 15, 2026 at 4:10 am

    a method can have only one return type, so you will need to forward the request to another controller method. Which controller method can depend on the result of your authentication …

        @RequestMapping ...
        public String handleRequest() {
            if(valid){
               return "forward:/path_to_my_another_controller";
            }else {
               return "forward:/somewhere_else";
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a spring action that I am rendering some json from the controller,
I have a Spring 3.0 application, with an Web Controller Method. This method normaly
I am trying to forward my request from a Spring-MVC controller method - to
If I have a RequestMapping in a Spring controller like so... @RequestMapping(method = RequestMethod.GET,
I have a Spring controller method that is correctly returning a collection of objects
I have Spring Controller, and a method like this: public ModelAndView getItems() { ModelAndView
First I have a Spring 3.0 controller with a method similar to the following.
I have been going through the tutorials of Spring 3 at http://www.vaannila.com/spring/spring-annotation-controller-1.html But i
I currently have a Spring MVC controller that takes a MultipartFile @RequestMapping(method = RequestMethod.POST)
I have implemented spring security in controller method. Below is my spring security.xml -->

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.