I want to redirect the user into last accessed page after session expire and i prompt user to login again. In that i passed last page url into one parameter and invoke a seesioerror action for validate the user.
I have this code snippet :
<script type="text/javascript">
var currentURL = window.location.href;
</script>
<%
String url= "<script>document.writeln(currentURL);</script>";
Object obj = session.getAttribute("user");
if (obj == null) {
response.sendRedirect(request.getContextPath() + "/SessionError?backurl=" + url);
}
%>
Now my problem is whenever I print the Java String varaible url using <% out.print("URL" + url);%>
it correctly print the page URL.
But If pass it on this line response.sendRedirect(request.getContextPath() + "/SessionError?backurl=" + url);
inside the snippet. It only pass <script>document.writeln(currentURL);</script>
not the current page url like http://www.mysite.com/home. Please help me to get rid of this problem.