Hi
Thank u for reply.i understood what the working of application/x-www-form-urlencoded.but can u tell me what the 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.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class CreateFile extends HttpServlet{
public void doGet(HttpServletRequest req,HttpServletResponse res) {
try {
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("<form method=post>");
out.println("<input type=text name=x>");
out.println("<input type=submit>");
out.println("</form>");
}
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);
dos.writeBytes(req.getParameter("x"));
file.close();
}
catch(IOException ex){System.out.println("Error "+ex);}
}
}