In my program i want to access to the other page filling the forms and getting in to the next page, but when i fill it in the right way nothing happend, when i make a mistake the page that are printed its incorrect, im not sure what is the problem, im not sure if i have to authenticate or something like that, plz help me
import java.net.*; import java.io.*; public class Conexion { public static void main(String[] args) { try { URL tec = new URL("https://millenium.itesm.mx/patroninfo~S63*spi/698390/patrate"); URLConnection tecConexion = tec.openConnection(); tecConexion.setDoInput (true); tecConexion.setDoOutput (true); tecConexion.setAllowUserInteraction(true); tecConexion.setUseCaches(true); tecConexion.connect(); // tecConexion.setUseCaches (false); DataOutputStream out; DataInputStream in;/* = new DataInputStream(tecConexion.getInputStream()); String inputLine; BufferedReader d = new BufferedReader(new InputStreamReader(in)); //while ((inputLine = d.readLine()) != null) { // System.out.println(inputLine); //}*/ out = new DataOutputStream (tecConexion.getOutputStream ()); String content = URLEncoder.encode("name", "UTF-8") + "=" + URLEncoder.encode("---", "UTF-8"); content +="&"+ URLEncoder.encode("code", "UTF-8") + "=" + URLEncoder.encode("---", "UTF-8"); content +="&"+ URLEncoder.encode("pin", "UTF-8") + "=" + URLEncoder.encode("---", "UTF-8"); /*"name=" + "----" + "code=" + "----"+ "pin="+ "----");*/ out.writeBytes (content); out.flush (); // Get response data. in = new DataInputStream (tecConexion.getInputStream ()); BufferedReader d= new BufferedReader(new InputStreamReader(in)); String str; while (null != ((str = d.readLine()))) { System.out.println (str); } in.close (); } catch (MalformedURLException e) { System.out.println("MalformedURLException: " + e); } catch (IOException e) { System.out.println("IOException: " + e); } } }