Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In your case (GET method) you need to pass the variables in the <strong>open</strong> method directly (at the end of the url)</p> <pre><code>xhr.open("GET", "http://csce:8080/test/index.jsp?id=c6c684d9cc99476a7e7e853d77540ceb", true); xhr.send(null); </code></pre> <hr> <p>Goyuix's technic is <strong>only</strong> correct in the case of the POST method:</p> <pre><code>xhr.open("POST", "http://csce:8080/test/index.jsp", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send("id=c6c684d9cc99476a7e7e853d77540ceb"); </code></pre> <hr> <p>You might want to use the <strong><em>uri encoding global function</em></strong> as a good practice in case you have spaces or other special characters in your parameter:</p> <p><strong>POST method:</strong></p> <pre><code>var myVar1 = encodeURIComponent("c6c684d9cc99476a7e7e853d77540ceb"); xhr.open("POST", "http://csce:8080/test/index.jsp", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send("id=" + myVar1); </code></pre> <p><strong>GET method:</strong></p> <pre><code>var myVar1 = encodeURIComponent("c6c684d9cc99476a7e7e853d77540ceb"); xhr.open("GET", "http://csce:8080/test/index.jsp?id=" + myVar1, true); </code></pre> <hr> <p>FYI, this is how you <strong>retrieve the parameters passed to the JSP page</strong>:</p> <p><em>We are using JSP's core library (this lib must be in your web app's /WEB-INF/lib/ directory) to output the value of the parameter called "id".</em></p> <pre><code>&lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %&gt; &lt;c:out value="${param.id}"/&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload