Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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>
 
We've gotta get close enough to that helmet to pull the choke on it's engine and flood his mind! Or, we could just read this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic