Forums Register Login

When to use forward in a jsp page?

+Pie Number of slices to send: Send
Hello,
I've searched the archives but didn't find my exact situation. I am trying to run some javascript code in my logout page that clears a users cookie then redirects back to the login page. If I remove my forward tag, the javascript code works fine but the user does not end up back at the login page when logging out. It doesn't seem to matter if I put the html that calls the javascript before or after the forwarding code. Any suggestions?
Thanks,
Richard
+Pie Number of slices to send: Send
Considering that the JSP code gets executed on the server and the Javascript gets executed on the client, no, it doesn't really matter what order they are in.
Can you drop a small snip of code for the relevant section?
Dave
+Pie Number of slices to send: Send
Hi Richard,
JSP code executes in the server side. Only the output of running a JSP (ie HTML with javascripts) comes to the client side. So this alone gets executed by the browser.
In your case you are running a client side javascript code to clear the user cookie & then you want to redirect to login page.
Adding this line to your js code(after you clear the cookies) should solve your problem.
window.location = "login.jsp";
And dont forget to comment the forward tag in your jsp.
Hope this helps
+Pie Number of slices to send: Send
After executing the javascript check if you are submitting the form to the page where you are using forward tag bcos forward is serverside code. If you want to redirection to take place in the client side itself use the script window.location.href = "loginPage.htm";
Slideshow boring ... losing consciousness ... just gonna take a quick nap on this tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 712 times.
Similar Threads
need help implementing logout
Logout problem
Two Forms Mistakenly Shown
getSession and isRequestedSessionIdValid
logic:redirect not working for me
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:57:56.