I want to send some data from desktop application to google awt servelet
I am currently trying this in my system (localhost) as I have installed eclipse plugin
I am sending data like this
URL url = new URL("http://localhost:8888/calendar");
URLConnection urlConnection = url.openConnection();
urlConnection.setDoOutput(true);
PrintWriter out = new PrintWriter(urlConnection.getOutputStream());
String stringTosend = URLEncoder.encode(tf.getText(), "UTF-8");
out.write(stringTosend);
AND MY SERVLET IS LIKE THIS
public class CalendarServlet extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/plain");
String input = req.getReader().readLine();
resp.getWriter().println(input);
}
}
But what I am getting back is NULL.