Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Need help with HTTP Post/Get in an applet/servlet environment

Avatar of HLRosenberger
HLRosenbergerFlag for United States of America asked on
File Sharing SoftwareJava App ServersJava EE
2 Comments1 Solution436 ViewsLast Modified:
I heed help with HTTP POST/GET in a client/servlet environment.  I want to write a Java client and servlet.  They will communicate via HTTP to POST/GET XML documents.  

This is using Apache Tomcat on the server side.

I have the start a client and servlet code.  My client applet can connect to the my server using this string:  ("http://localhost:8080/IPCServer");

IPCServer is the name of my servlet.  By using my browser and entering the connection string, I get a response from my servlet - it puts out some HTML to the browser.  However, I can't get my servlet to respond to my client applet.  Below is the code in my applet.  What am I doing wrong?  


            //urlConn.setRequestProperty("User-Agent", "BlackBerry");

            //Content-Type is must to pass parameters in POST Request
            //urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            urlConn.setRequestProperty("Content-Type", "text/xml");

            String testData = URLEncoder.encode("This is my test data", "UTF-8");

            OutputStreamWriter out = new OutputStreamWriter(urlConn.getOutputStream());

            out.write("string=" + testData);
Avatar of Mick Barry
Mick BarryFlag of Australia imageJava Developer
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answers