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.

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) %>'">

Recommended Answers

All 2 Replies

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;

<!-- more code -->
<input type="button" value="Copy" onclick="redirectUser();">
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.