PDA

View Full Version : how to redirect to another jsp from java



rushi2440
8 Apr 2012, 11:15 PM
Hi.. sencha forum member

I am having some problem with redirect to another jsp page from my java class.

I am using spring 3.0, JPA and extjs 4.0.

I am having login form which takes the username and password from the user and on server side after proper verification, I will redirect them to valid jsp page.

I am using the below code to redirect to another jsp page

private String LOGIN_PAGE = "../index.jsp";


@RequestMapping(value = "/login/GetLoginCheck.action")
public void sitemap (HttpServletRequest request, HttpServletResponse response) throws Exception {
try {
System.out.println("QUERY TO GET LOGIN");
response.sendRedirect(LOGIN_PAGE);
return ;
} catch (Exception e) {
return ;
}
}


but don't know why the jsp page didn't get opened instead I just get the requested full page to my firebug console as response as below image
33757


so kindly please suggest me what's wrong with my above code.


Yogendra Singh
Sr. Programmer
Kintudesigns.com

scottmartin
9 Apr 2012, 11:00 AM
I am unable to see your screenshot, but are you getting the correct information back to the client from the server?

Can you just redirect to the page send back from the server using: window.location = URL;

Regards,
Scott.

börn
10 Apr 2012, 3:49 AM
yap unfortunately - if you submit your form - the ext form makes an ajax request and waits for a success message made by the server. If you want a standard form submit behaviour you have to set standardSubmit:true.

Alternatively as said in the answer above you can redirect manually with "document.location.href" in the success callback function of your js-submit function (so you have to send a success-object to the client in your server's method instead of making a redirect).

börn
10 Apr 2012, 3:51 AM
besides you should consider using spring-security if using spring-mvc already.