Results 1 to 2 of 2

Thread: how to map from servlet to servlet?

  1. #1
    Join Date
    Oct 2007
    Posts
    3

    Default how to map from servlet to servlet?

    Hi all,

    i will like to ask this question. The current spring example illustrate on mapping from a controller to a jsp page.What if i have to do in certain situations such as from this controller go to another controller before reaching a jsp page , as my concept always go through a controller first before reaching a view,so if for example login page unsuccessful eg.loginController unsuccessful -> startingController b4 outputting desired result in a jsp page.BTW i'm quite a noob..so asking quite a lot.i will be grateful if there's some examples to illustrate thanks.

  2. #2
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    There's nothing to prevent your controllers from knowing about each other through dependency injection. E.g.

    Code:
    public class LoginController implements Controller {
    
        private Controller startingController; // setter ommitted
    
        public ModelAndView handleRequest(...) {
            ...
            if (unsuccessful) {
                return startingController.handleRequest(...);
            }
            return ...;
        }
    
    }
    But that's also not the only way to implement this kind of rule (e.g. Spring Security uses a ServletFilter to detect and redirect on unsuccessful authentication).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •