Question

after login I want user to redirect to same webpage how to do that.

Is there any way to send page url to server. So that server can know from which page request has came.

Is there a way to send information to server other than input fields in html from client to server.

Pas de solution correcte

Autres conseils

You can save the current page to the session in each page, for every page but the login page. Then after login redirect to the value of the current page parameter from the session if one exists, and to the index if it doesn't.

In each page:

session.setAttribute("currentpage", pagename);

In the login code:

String pagename = (String)session.getAttribute("currentpage");
if(pagename == null)
{
    pagename = "index.jsp";
}
response.sendRedirect(pagename);

you can create a filter and then check for this and redirect

if(session != null && !session.isNew())
    chain.doFilter(request, response);
else
    response.sendRedirect("/myhomepage.jsp");

Another one Interesting Answer is following as:

redirect a page in JSP. You can see in the given example that have been used to the method of response.sendRedirect() through which the server sends the response to the client browser, from where the next request comes and it displays that url correctly. You can also redirect the jsp page in a jsp.

Here is the code of redirect.jsp

<html>
<%
String redirectURL = "http://www.stackoverflow.net/";
response.sendRedirect(redirectURL);
%>
</html> 
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top