javascript - How can I pass a variable to a JSP class using the URL? -
I am trying to modify a java script so send a URL variable (called creator) to a Java class Able to The interesting thing is that the file is an HTML file with Javascript because I'm new to JSP, I'm not even sure this can be done, but here's HTML / JavaScript code:
< Code> & lt; Html & gt; & Lt; Top & gt; & Lt; Script type = "text / javascript" & gt; Var url = "\ QWMASMatch"; // server-side script function table () {var currentTime = new date (); Var ele = document.getElementById ('Table'); Function Handle HttpResponse () {if (http.readyState == 4) {ele.innerHTML = http.responseText; }} Var http = getHTTPObject (); // We create the HTTP object var tempUrl = url; String creator = request.getParameter ("manufacturer"); If (manufacturer! = Null & amp;! Manufacturer.exls ("")) {http.open ("GET", tempUrl + "?" + "Manufacturer =" + creator, true); Http.onreadystatechange = handleHttpResponse; Http.send (zero); } And {http.open ("GET", tempUrl + "?" + "Time =" + current time, true); Http.onreadystatechange = handleHttpResponse; Http.send (zero); }} Function getHTTPObject () {var xmlhttp; Try / * @ Cc_on @if (@_jscript_version> = 5) {xmlhttp = New ActiveXObject ("Msxml2.XMLHTTP"); } Hold (e) {try {xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP"); } Hold (e) {xmlhttp = false; }} @ELse xmlhttp = false; @ And @ * / if (! Xmlhttp & amp; amp; amp; amp; amp; type xmlhttp = new XMLHttpRequest;); } Hold (e) {xmlhttp = false; }} Return xmlhttp; } & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Img src = 'enet.jpg' & gt; & Lt; Div class = 'title' & gt; QuoteWerks-2-Month & lt; / Div & gt; & Lt; Div id = "table" & gt; It is loading . . & Lt; / Div & gt; & Lt; Script type = "text / javascript" & gt; Table () & lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt; I am trying to pass a URL link
and return the value back to that page Where it is expected that will be raised from the class.
I have added the segment
string creator = request.getParameter ("creator"); If (manufacturer! = Null & amp;! Manufacturer.exls ("")) {http.open ("GET", tempUrl + "?" + "Manufacturer =" + creator, true); Http.onreadystatechange = handleHttpResponse; Http.send (zero); } And {http.open ("GET", tempUrl + "?" + "Time =" + current time, true); Http.onreadystatechange = handleHttpResponse; Http.send (zero); }
... in the table () function. I am more familiar with PHP, and those files usually have a PHP extension, but in this case, using the original file HTML, one Java with a second segment in a Java QWMASMatch class Is there any idea that I can do wrong in passing?
Whenever I try to type just, the script still resolves the other section
Thanks in advance
Should this value be slashed further? \ QWMASMatch
It looks like a side-side code that is mixed with JS:
string creator = request.getParameter ("creator"); Maybe your intentions:
var creator = '& lt;% out.println (request.getParameter ("creator")); % & Gt; '; ... Use & lt; %%> to tell JSP to execute the code contained on the server.
Comments
Post a Comment