Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Servlets
Search Coderanch
Advance search
Google search
Register / Login
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
Tim Cooke
Liutauras Vilda
Jeanne Boyarsky
paul wheaton
Sheriffs:
Ron McLeod
Devaka Cooray
Henry Wong
Saloon Keepers:
Tim Holloway
Stephan van Hulst
Carey Brown
Tim Moores
Mikalai Zaikin
Bartenders:
Frits Walraven
Forum:
Servlets
Receiving J2ME data on the servlet page
nitish dhar
Greenhorn
Posts: 11
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I have sent a value from the J2ME page to the
servlet
String url = "http://localhost:8080/ChatServlet/ChatServlet" ; hc = (HttpConnection)Connector.open(url); hc.setRequestMethod(HttpConnection.POST); hc.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); hc.setRequestProperty("Content-Length",Integer.toString(_output.length())); os = hc.openDataOutputStream(); System.out.println(_output.getBytes()); os.write(_output.getBytes());
Now how do i print this value on the servlet page
I tried something shown below but that is not helping .... please help!
// int size = req.getContentLength();(i dont know why but this is returning -1 so i found size using another way below) byte[] httpInData = new byte[1024]; ServletInputStream httpIn = req.getInputStream(); size =httpIn.read(httpInData); httpInData = new byte[size]; String str = new String(httpInData,req.getCharacterEncoding());//this is giving null pointer exception becuz req.getCharacterEncoding() is also not working System.out.println("str"+str);
Is there any other way i can print the data
What are you doing in my house? Get 'em tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
HttpConnection
HTTPS / MIDP 1.0
Multiple URLConnections
HTTP connection thread problem to SERVLET on APACHE
Reading Word Doc
More...