• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

URLConnection not working in IE but fine in Netscape

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a very peculiar problem. I have made a applet which is supposed to communicate with a servlet and store data in a database. Now the problem is that when i am running the applet in Netscape Navigator everything is occuring perfectly
fine, but with Microsoft Explorer 5.0 everything goes wrong.
The concept is that in an HTML page the moment a person moves his mouse over a link (any link) the link is to be recorded in the database. What i have done is that with the applet i am sending two parameters. Now the javascript senses the movement of mouse over the links and changes the parameters. Once there is a change of parameters the applet communicates
with the servlet and the data is recorded. This is working fine in Netscape Navigator, however in Internet Explorer 4.0/5 nothing happens. The connection is not made nor is any exception thrown I am sending to you the codes for the applet, javascript.
Pls. check this for me and advise.
Thanks
Hemant Gupta
Code for Applet
Tracker.java

import java.applet.*;
import java.net.*;
import java.io.*;
import java.util.*;
public class tracker extends Applet implements Runnable{
public String currentlink;
public boolean timeit;
String username;
String page;
Thread th;
Date startedAt;
public void start()
{
if(th==null)
{
th=new Thread(this);
th.setPriority(4);
th.start();
}
}
public void init()
{
timeit=false;
startedAt=new Date();
username=getParameter("user");
page=getDocumentBase().toString();
currentlink="none";
}
public void run(){
String xyz=currentlink;
while(true)
{
if(timeit)
{
startedAt=new Date();
timeit=false;
}
if(!xyz.equals(currentlink))
{
Date now=new Date();
int duration=(int)(now.getTime()-startedAt.getTime());
try
{
if(duration>500)
{
URL listURL = new URL("http://www.pentaclick.com/servlet/ads.mouseact.class?"+URLEncoder.encode("user";)+"="+URLEncoder.encode("sd"+username)+"&"+URLEncoder.encode("link")+"="+URLEncoder.encode(curre ntlink)+"&"+URLEncoder.encode("time")+"="+URLEncoder.encode(String.valueOf(duration).trim())+"&"+URLEncoder.encode("page")+"="+URLEncoder.encode(page));
URLConnection listConn = listURL.openConnection();
listConn.setDefaultUseCaches(false);
listConn.setUseCaches(false);
listConn.connect();
showStatus("Tracking now");
}
Thread.sleep(500);
}catch(Exception ex){
showStatus(ex.toString());
}
xyz=currentlink;
startedAt=now;
}
}
}
public void stop(){
try{
URL listURL = new URL("http://www.pentaclick.com/servlet/ads2.timecheck.class?user=sd"+username);
URLConnection listConn = listURL.openConnection();
listConn.setDefaultUseCaches(false);
listConn.setUseCaches(false);
listConn.connect();
}catch(Exception ex){
}
}
}

Code for Javascript
function changeOfParams(nm)
{
if(navigator.appName=="Netscape")
document.dctracker.currentlink=nm;
else
document.all.dctracker.currentlink=nm;
}
function changeOfTimer()
{
if(navigator.appName=="Netscape")
document.dctracker.timeit=true;
else
document.all.dctracker.timeit=true;
}

Html File
<html>
<head>
<title>Demo page</title>
<Script language="JavaScript" src="tracker.js">
<!--
//-->
</script>
</head>
<body>
<applet name=dctracker code=tracker.class width=1 height=1>
<param name=user value=lalu>
<param name=link value=none>
</applet>
<a href="a.html" onMouseOver=changeOfTimer() onMouseOut='changeOfParams("a.html")'>a link</a><br>
<a href="b.html" onMouseOver=changeOfTimer() onMouseOut='changeOfParams("b.html")'>b link</a><br>
<a href="c.html" onMouseOver=changeOfTimer() onMouseOut='changeOfParams("c.html")'>c link</a><br>
<a href="d.html" onMouseOver=changeOfTimer() onMouseOut='changeOfParams("d.html")'>d link</a><br>
</body>
</html>
 
Popeye has his spinach. I have this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic