Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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

can't an applet connect to two different servlets?

 
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.
 
Bartender
Posts: 9612
16
Mac OS X Linux 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"
 
You can thank my dental hygienist for my untimely aliveness. So tiny:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic