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

can't an applet connect to two different servlets?

 
kelly goedert
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can 't I have two HttpURLConnections in the same applet? I have this code:
private HttpURLConnection con;
private HttpURLConnection con2;
public void init() {
con = abreConexao("http://localhost:8080/hardkey/checar?checa=true");
con2 = abreConexao("http://localhost:8080/hardkeydevolver?test=true");
try{
ObjectInputStream inputFromServlet = new ObjectInputStream(con.getInputStream());
inputFromServlet.close();
ObjectInputStream inputFromServlet2 = new ObjectInputStream(con2.getInputStream());
inputFromServlet2.close();
}
catch(IOException e){
e.printStackTrace();
e.getMessage();
}
}
All the method abreConexao() does is open an connection to the url I send to it.
In the servlets all I have is a println in the doGet method. Why I can see the output from the first servlet but not from the second??
I'm stuck in this for days, please help.
 
Joe Ess
Bartender
Posts: 9340
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kelly goedert:



Your URL's servlet paths are different. I think you are missing a forward slash in "hardkeydevolver"
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic