954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

pass session variable with window.location.href jsp

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.

<input type="button" value="Copy" onClick="window.location.href='<%= response.encodeURL("http://www.mysite/index.jsp?switch="+ intvariable) %>'">
MrJody
Newbie Poster
1 post since Jun 2008
Reputation Points: 10
Solved Threads: 0
 

Your quoting seems to be off. Try something like:

<script type="text/javascript">
function redirectUser() {
  var url = '<%= response.encodeURL("http://www.mysite/index.jsp?switch="+ intvariable) %>';
  window.location.href = url;
}
</script>

<!-- more code -->
<input type="button" value="Copy" onclick="redirectUser();">
~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 
sarathpetec
Newbie Poster
1 post since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You