Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Web Services
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
DevSecOps Adventures: A Game-Changing Approach with Chocolate, LEGO, and Coaching Games
this week in the
Agile and Other Processes
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
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Paul Clapham
Devaka Cooray
Tim Cooke
Sheriffs:
Rob Spoor
Liutauras Vilda
paul wheaton
Saloon Keepers:
Tim Holloway
Tim Moores
Mikalai Zaikin
Carey Brown
Piet Souris
Bartenders:
Stephan van Hulst
Forum:
Web Services
HTTPConnection in mobiles
feda alshahwan
Ranch Hand
Posts: 170
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I created a code to set up RESTful web server and I tried using HTTpConnection to extract the HTTP headers but unfortunately I got Casting Exception error?
Does anybody know the reason ?
public void run(){ ServerSocketConnection scn =null; try{ scn=(ServerSocketConnection) Connector.open("socket://:30000"); }catch (IOException ex){ ex.printStackTrace(); } while (true) { try{ form.append("Waiting for Client Request........"); HttpConnection httpc; httpc= (HttpConnection) scn.acceptAndOpen(); form.append("Request Accepted on host address :"+scn.getLocalAddress()+" And on Port number:" +scn.getLocalPort()); RequestHandler RH=new RequestHandler (httpc); }catch (IOException ex){ ex.printStackTrace(); } } } public class RequestHandler extends Thread{ HttpConnection httpc; String requestMethod; RequestHandler (HttpConnection httpc){ httpc=this.httpc; start(); } public void run(){ InputStream is = null; try { is = httpc.openInputStream(); } catch (IOException ex) { ex.printStackTrace(); } OutputStream os = null; try { os = httpc.openOutputStream(); } catch (IOException ex) { ex.printStackTrace(); } try{ httpc.getRequestMethod(); }catch (Exception e){ e.printStackTrace(); } try { os.write("WelCome Client".getBytes()); } catch (IOException ex) { ex.printStackTrace(); } try { os.flush(); } catch (IOException ex) { ex.printStackTrace(); } try { os.close(); } catch (IOException ex) { ex.printStackTrace(); } } }
Liar, liar, pants on fire! refreshing plug:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
httpConnection limted?
JSP -> Servlet and form bean.
sending mail using servlet
Sockets in J2ME
MY server just hanged
More...