This week's giveaway is in the Threads forum.
We're giving away four copies of Java Concurrency Live Lessons and have Doug Schmidt on-line!
See this thread for details.
Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HttpURLConnectin, Sockets and Servlet problem  RSS feed

 
Isaac Jones
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i'm trying to build a messenger using jsp, servlets and applets. the server is a servlet. when you start it, the init() method will be called and a socketlistener on port 8051 will be opened. this works just fine. now i want to connect with my client (an applet) to this servlet over a HttpURLConnection. i can't get this to work somehow. i want to transfer messages through the URLConnection with this setRequest property. but somehow the message is not transfered. what am i doing wrong here? and also i want to write a message to the server using the printwriter. shouldn't the socketlistener be able to get and display this message? well i've no idea what i'm doing wrong. i hope someone can help. thanks already. here's the code:


 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why in the name of sanity do you expect your socket on 8051 to handle HttpURLConnections?
You appear to have the servlet init method Thread stuck forever.
The whole idea of servlet containers like Tomcat is to have the servlet container handle the basic connectivity and interpretation of HTTP requests so your servlet does not have to.
Go read a servlet tutorial and create some basic servlets before jumping into the middle of a complex project.
Bill
 
Isaac Jones
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well...thanks for you answer. it didn't help me that much though. so you wanna say that i can't connect to a socket with a urlconnection. or does this just doesn't make sense? isn't this multi-threaded? i should be able to get into the dopost / doget function, shouldn't i?
i've read thru some tutorials... but they didn't help a lot. so if anyone got any ideas.. i'm glad for any input...

thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!