pass session variable with window.location.href jsp

Reply

Join Date: Jun 2008
Posts: 1
Reputation: MrJody is an unknown quantity at this point 
Solved Threads: 0
MrJody's Avatar
MrJody MrJody is offline Offline
Newbie Poster

pass session variable with window.location.href jsp

 
0
  #1
Aug 19th, 2008
Hello,
I would like to use a button as a link and pass the session variable in a jsp!
The below code should work.
Any help is appreciated.
Thanks.

I use encodeURL if the user has cookies off.
This works with links but not when using an input button with window.location.href.

  1. <input type="button" value="Copy" onClick="window.location.href='<%= response.encodeURL("http://www.mysite/index.jsp?switch="+ intvariable) %>'">
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,609
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 464
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: pass session variable with window.location.href jsp

 
0
  #2
Aug 20th, 2008
Your quoting seems to be off. Try something like:
  1. <script type="text/javascript">
  2. function redirectUser() {
  3. var url = '<%= response.encodeURL("http://www.mysite/index.jsp?switch="+ intvariable) %>';
  4. window.location.href = url;
  5. }
  6. </script>
  7.  
  8. <!-- more code -->
  9. <input type="button" value="Copy" onclick="redirectUser();">
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the JSP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC