Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

When to use forward in a jsp page?  RSS feed

 
Richard Elsberry
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Vijayanandh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
sampy jagan
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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";
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!