Hello I have a problem when I try to submit a form. I get the html page which has the form with this code: URL u = new URL("http://www.mypage.my"); URLConnection uc = u.openConnection( ); uc.setDoOutput(true); OutputStreamWriter out= new OutputStreamWriter(uc.getOutputStream( ), "ASCII");
I complete the form with this code
out.write("name=MyName\n"); ............
And I get the response by this code: InputStream in = uc.getInputStream(); int c; while ((c= in.read())!=-1) { System.out.print((char) c); }
The problem is that the respone is the old page, not the new page that should be by submitting the form.
I am not sure to what page you are submiting the values too. But, try passing the values as query string as show below. Put the name of the jsp in place of <your jsp page>.
URL u = new URL("http://www.mypage.my/<your jsp page>?name=MyName");