I'm trying to modify someone's written JavaScript code to pass a URL variable (called manufacturer) into a Java class. The interesting thing is the file is an HTML file with JavaScript. Because I'm new to JSP, I'm not even sure if this can be done but here is the HTML/JavaScript code:
<html>
<head>
<script type="text/javascript">
var url = "\QWMASMatch"; // The server-side script
function Table(){
var currentTime=new Date();
var ele = document.getElementById('Table');
function handleHttpResponse()
{
if (http.readyState == 4) {
ele.innerHTML = http.responseText;
}
}
var http = getHTTPObject(); // We create the HTTP Object
var tempUrl = url;
String manufacturer = request.getParameter("manufacturer");
if ( manufacturer != null && !manufacturer.equals(""))
{
http.open("GET", tempUrl+"?"+"manufacturer="+manufacturer, true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
} else {
http.open("GET", tempUrl+"?"+"Time="+currentTime, true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
}
function getHTTPObject(){
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch (e){
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
</script>
</head>
<body>
<img src='enet.jpg'>
<div class='title'>
QuoteWerks-2-MAS</div>
<div id="Table">Loading . . . </div>
<script type="text/javascript">
Table()</script>
</body>
</html>
I'm trying to pass a url link
and pass the value back into the page where it is hopefully picked up by the class.
I added the segment
String manufacturer = request.getParameter("manufacturer");
if ( manufacturer != null && !manufacturer.equals(""))
{
http.open("GET", tempUrl+"?"+"manufacturer="+manufacturer, true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
} else {
http.open("GET", tempUrl+"?"+"Time="+currentTime, true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
...in the Table()
function. I'm more familiar with PHP, and those files usually have a PHP extension however in this case, the original file is using HTML to pass a variable into a Java QWMASMatch
class with just the else clause. Any ideas what I could be doing wrong?
The script seems to still be resolving to the else clause when I attempt to just type in
thanks in advance