This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Joe Ess

HttpURLConnection  RSS feed

Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to submit a simple form using threading.
URL cellUrl = new URL("");
HttpURLConnection conn = (HttpURLConnection) cellUrl.openConnection();
conn.setRequestProperty ("Content-Type", "application/x-www-form-urlencoded");
DataOutputStream dos = new DataOutputStream (conn.getOutputStream ());
dos.writeBytes (strData);
dos.flush ();
dos.close ();
i am using this code but it is not.and what is problem with my code.
it do not submit any data to form.the code of form is given below and it is present in get method of servlet and data is submit on the post method of same servlet.i want to submit my data into post method using HttpURLConnection.
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class CreateFile extends HttpServlet{

public void doGet(HttpServletRequest req,HttpServletResponse res) {
try {
PrintWriter out=res.getWriter();
out.println("<form method=post>");
out.println("<input type=text name=x>");
out.println("<input type=submit>");
catch(IOException ex){System.out.println("Error "+ex);}
public void doPost(HttpServletRequest req,HttpServletResponse res) {

try{ System.out.println("Creating File");
FileOutputStream file=new FileOutputStream("String.txt");
DataOutputStream dos=new DataOutputStream(file);

catch(IOException ex){System.out.println("Error "+ex);}
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!