user1277996
user1277996

Reputation: 133

Forwarding jsp from controller

I have a boolean function in a java class.. the function returns true if executed else it has to be directed to a jsp page how do I do that.. I am not using any creation of objects nor req.getParameter().. I tried using redirectView(), its a function and getting errors. Its something like..

boolean isValidate()
{

}

if(isValidate())
   return true;
else

Upvotes: 1

Views: 746

Answers (2)

Pau Kiat Wee
Pau Kiat Wee

Reputation: 9505

Try on your controller

Normal GET:

return "path/to/jsp";

Redirect:

return "redirect:/login";

When use redirect prefix, it will return to http://host/yourapp/login

Spring documentation for redirect prefix

For redirect example:

@RequestMapping(value = "/logout", method = RequestMethod.GET)
public String logoit() {
    return "redirect:/";
}

Upvotes: 2

nickdos
nickdos

Reputation: 8414

Assuming your controller method returns a String, you can do:

return "redirect:/path/to/page";

Upvotes: 1

Related Questions