Abhinav Anant
Abhinav Anant

Reputation:

How should I redirect the second page in Spring framework

My application has 3 JSP pages: one is login.jsp, and the others are loginSuccess.jsp and loginFail.jsp. If the username and the password in the login form are correct then it goes to the loginSuccess page but when the username and password are not correct, it doesn't go to the loginFail page.

What do I need to do to get it to work?

Upvotes: 1

Views: 3212

Answers (4)

Arun P Johny
Arun P Johny

Reputation: 388316

If you don't want to use Spring Security, I think you can use spring mvc RedirectView to redirect the request to differenct pages.

    if (success) {
        return new ModelAndView(new RedirectView("loginSuccess.jsp"));
    } else {
        return new ModelAndView(new RedirectView("loginFail.jsp"));
    }

Upvotes: 1

serg
serg

Reputation: 111265

You can also use AbstractWizardFormController if Spring Security is an overkill.

Upvotes: 0

Romeo Foxtrot
Romeo Foxtrot

Reputation: 71

Spring Security has properties in the config xml. Something like this should do the trick!

    default-target-url="loginSuccess.jsp" 
    authentication-failure-url="/loginFail.jsp"

Upvotes: 2

Martin K.
Martin K.

Reputation: 4703

Use Spring Security

Upvotes: 2

Related Questions