Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem invoking servlet using applet

 
sunil kumre
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I've written an applet to invoke a servlet it gives the foll error message==>

Connection rejected: 'Login timed out after: '5000' ms on socket: 'Socket[addr=127.0.0.1/127.0.0.1,port=16
here's what my applet looks like==>
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
/*
<applet code="ReadWriteApp" width="400" height="400">
</applet>
*/
public class ReadWriteApp extends Applet implements ActionListener{
Button Connect;
TextField tf;
public void init(){
tf = new TextField();
Panel p = new Panel();
Connect = new Button("Connect");
Connect.addActionListener(this);
p.add(Connect);
p.add(tf);
add(p);
}
public void actionPerformed(ActionEvent ae){
tf.setText("sunil");
callServlet();
}
public void callServlet(){
try{
URL url = new URL("http://localhost:7001/MyCom");
String qry = URLEncoder.encode("sunil")+ "=" + URLEncoder.encode("sunilkumre");
URLConnection uc = url.openConnection();
uc.setDoInput(true);
uc.setDoOutput(true);
uc.setUseCaches(false);
uc.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
uc.setRequestProperty("Content-length", "" + qry.length());
// Write out post data
DataOutputStream out = new DataOutputStream(uc.getOutputStream());
out.writeBytes(qry);
out.flush();
out.close();
}
catch(MalformedURLException me){
}
catch(IOException me){
}
}
}
What could be the problem?
thanks in advance
Sunil.
 
Tim Holloway
Saloon Keeper
Posts: 18365
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a webserver running on your local machine? Since you're using port 7001, probably WebLogic? And was the servlet loaded via a page from that local webserver or did you just try to load it drectly>
If you can't type the URL in a web browser's address control and get a response, the applet won't be able to get a response either.
 
sunil kumre
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Yes i've a webserver running on local machine.I'm using weblogic.
The page(an html file:this embeds the applet)is loaded from a dir under weblogic when the server is running.
Also i tried invoking the servlet directly by typing the url in the browser and it gets invoked.
But the same is not happening thro applet.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic