Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: URL Problem

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile URL Problem

    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);
    	      }
    	   }
    	}


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: URL Problem

    when i fill it in the right way nothing happend, when i make a mistake the page that are printed its incorrect
    Can you show us what is "printed" ( I assume you mean displayed on the console not printed on paper).
    How do you "fill it in"?

  3. #3
    Junior Member
    Join Date
    Jun 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: URL Problem

    it display just the html code but with that i know that i cant access to the page, that html is when you put a wrong name code and pin, but when you put the right code i only get the page like this:
    https://millenium.itesm.mx/patroninfo~S63*spi/698390/patrate
    the same page like nothing happend

    <!-- 2006 WebPAC Pro Version, set from 22 August, 2006 -->
    <!-- This file last changed: 17 August, 2006 -->
    <html  dir="LTR">
    <head>
    <title>Bibliotecas del Tecnológico de Monterrey                              /CIB</title>
    <base target="_self"/>
    <link rel="stylesheet" type="text/css" href="/scripts/ProStyles.css" />
    <link rel="stylesheet" type="text/css" href="/screens/styles.css" />
    <link rel="shortcut icon" type="ximage/icon" href="/screens/favicon.ico" />
    <script language="JavaScript" type="text/javascript" src="/scripts/common.js"></script>
    <script language="JavaScript" type="text/javascript" src="/scripts/features.js"></script>
    <script language="JavaScript" type="text/javascript" src="/scripts/webbridge.js"></script>
    <script language="JavaScript">
    <!-- Hide the JS
    startTimeout(6000000, "/");
    // -->
    </script>
    <noscript>
    <meta http-equiv="Refresh" content="6000;URL=/" />
    </noscript>
     
    <script type="text/javascript" src="/screens/bibdisplay.js"></script><script type="text/javascript" src="/screens/brief.js"></script><!--[if lte IE 8]><link rel="stylesheet" media="all" type="text/css" href="/screens/ie_styles.css" /><![endif]-->
    </head>
    <body bgcolor="#FFFFFF" onLoad='if (document.forms.length > 0) { for (var i=0; i<document.forms[0].elements.length; i++) { if (document.forms[0].elements[i].type == "text") { document.forms[0].elements[i].focus(); document.forms[0].elements[i].select(); return; } } }'>
    <!-- begin toplogo.html file -->
    <script type="text/javascript" src="/screens/src.js"></script>
     
    <div id="topLogohead">
      <div style="float:left; padding:0; margin:0">
        <div id="topLogoITESM"><a href="http://www.itesm.edu"><img src="/screens/logo.gif" alt="Tecnol&oacute;gico de Monterrey" border="0"/></a></div>
      </div>
     
      <div align="right" style="float:right; padding:10; margin:0">
        <div id="topLogoImage"><a href="/"><img src="/screens/logo_bibliotecas.gif" alt="Bibliotecas del Tecnol&oacute;gico de Monterrey" border="0"  /></a></div>
      </div>
     
      <div style="clear:both;"></div>
      <table width="100%" cellpadding="0" cellspacing="0" >
        <tr>
          <td width="223px"><div id="topLogoBanner_izq">&nbsp;</div></td>
          <td><div id="topLogoBanner_barra">&nbsp;</div></td>
          <td width="223px"><div id="topLogoBanner_der">&nbsp;</div></td>
        </tr>
      </table>
    </div>
     
    <table id="tablaContenido" cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td id="tdIzquierda" valign="top"><div id="columnaIzquierda">
        <div id="cuadroLogin" class="cuadroLogin">
          <br><div align="center"><a href="/patroninfo*spi"><img src="/screens/ret2prec2_spi.gif" class="button" alt="Mi cuenta" border="0"></a></div>
          <br><div align="center"><a href="#" onclick="return open_new_window( '/pinreset*spi' )"><img src="/screens/boton_obt_mod_NIP.gif" class="button" alt="Obtener/ modificar NIP" border="0"></a></div><br>
        </div>
            <ul id="menu1" class="menu">
              <li><a href="/search">Inicio</a></li>
              <li><a href="http://millenium.itesm.mx/screens/p_entrecampus.html">Pr&eacute;stamo Entre Campus</a></li>
              <li><a href="http://millenium.itesm.mx/screens/p_ill.html">Pr&eacute;stamo Interbibliotecario</a></li>
              <li><a href="http://biblioteca.itesm.mx/cgi-bin/mil/nuevasadq_millennium">Nuevas adquisiciones</a></li>
              <li><a href="http://biblioteca.itesm.mx/nav_millennium/mi_compra.php">Sugerir una compra</a></li>
              <!--  <li><a href="/openurlform?genre=article">Encontrar un art&iacute;culo</a></li> -->
              <li><a href="http://biblioteca.itesm.mx/nav_millennium/ayuda_contacto.php">Enviar sus comentarios</a></li>
              <li><a href="http://millenium.itesm.mx/screens/ayuda_guias.html">Ayuda y gu&iacute;as</a></li>
            </ul>
            <br><div align="left"><font color="#ff6600"><a target="_blank" href="http://serviciosva.itesm.mx/programaeditorial/DLibro10/Libro10.html"><b>Eventos por el D&iacute;a Internacional del Libro y los Derechos de Autor</b></a></font></div>
            <br><div align="center"><a target="_blank" href="http://www.itesm.mx/ele"><img src="/screens/logo_ele.jpg" class="button" alt="EBSCO Mobile" border="0" /></a></div>
            <br><div align="center"><a target="_blank" href="http://millenium.itesm.mx/screens/guia_uso_ene_2010.pdf"><img src="/screens/boton_politicas.gif" class="button" alt="Normas" border="0"></a></div>
            <br><div align="center"><a target="_blank" href="http://millennium.itesm.mx/screens/page_ebsco_mobile.html"><img src="/screens/EBSCO_Mobile.jpg" class="button" alt="EBSCO Mobile" border="0" /></a></div>
          </div>
      </td>
      <td  valign="top"><div id="barraCentro">
    <!--end toplogo.html-->
     
    <br>
    <style>
    #cuadroLogin { padding:2px; padding-left:5px; background-color:#FBEFAE; border: #f3b315 solid 1px; display:none;}
    </style>
    <div id="SuperSugiere">
      <FORM METHOD=POST>
        <FONT COLOR=RED SIZE= 2>
          <EM>
    La información introducida no es válida. Inténtelo de nuevo, por favor.      </EM>
        </FONT><BR>
        <h2>
        <!--<img src="screens/candado.gif" width="30" height="38">-->
        <b>Para esta funci&oacute;n, requerimos que se identifique como alumno o empleado del Tecnol&oacute;gico de Monterrey.
        </b><BR><BR>
    Introduzca la siguiente información:<br />    </h2>
        <div class="cuadroLoginIntero" style="width:53%;">
    <span id="nameprompt"><b>Ingrese su primer apellido: </b></span>      <BR>
    <input name="name" value="---" size="40" maxlength="40">      <FONT SIZE=-1>
    <BR>"L&oacute;pez" o "Del R&iacute;o"<BR>      </FONT><BR>
    <span id="codeprompt"><B>Matr&iacute;cula o N&oacute;mina:</B></span>      <BR>
    <input name="code" value="---" size="40" maxlength="40">      <FONT SIZE=-1>
    <BR>Alumnos: (A0##)<BR>Empleados: (L0##)<BR>Empleados TecMilenio (N##)<BR>          </FONT><BR>
    <span id="pinprompt"><b>Ingrese su NIP: </b></span>      <BR>
    <input name="pin" type="PASSWORD" value="" size="40" maxlength="40">      <FONT SIZE=-1>
    <br>(NIP NUM&Eacute;RICO utilizado en  el Servicio de Autopr&eacute;stamo)      </FONT>
          <BR>
          <BR>
    <input type="image" src="/screens/pat_submit_spi.gif" class="button" border="0" name="submit" value="submit" />
          <BR>
    <form>
    <a href="/logout~S63*spi?" target="_self"><img src="/screens/startover_spi.gif" class="button" alt="Comenzar Nuevamente" border="0" /></a>
    <br />
    </form>
        </div>
     
      </FORM>
      <BR>
      <b>&iquest;No tienes u olvidaste tu NIP?</b><BR>
      <ul>
        <li>
    <a href="#" onclick="return open_new_window( '/pinreset~S63*spi' )">&iquest;Olvid&oacute; su NIP?</a>    </li>
      </ul>
      * La Biblioteca Digital solo est&aacute; disponible para <B>alumnos</B> actualmente cursando preparatoria, licenciatura o posgrado o <B>empleados</B> con n&oacute;mina vigente del ITESM o TecMilenio.
    </div>
    <br />
    <!-- begin botlogo.html file -->
     
    </div>
    </td>
    <td id="tdDerecha" valign="top">
    <!--Begin the bottom logo table-->
    <div id="columnaDerecha"> 
      <!-- Titluo de la columna derecha-->
      <div class="tituloCuadro">Informaci&oacute;n</div>
          <!-- ligas de la columna derecha --> 
        <ul class="menu">
          <li>Bases de datos locales en la secci&oacute;n >> <a href="/screens/bibliotecas.html">Biblioteca de tu Campus</a></li>
        </ul><br/>
      <div class="tituloCuadro">Otros portales</div>
        <ul class="menu">      
          <!-- Otros Portales -->
          <li><a target="_blank" href="http://www.itesm.edu">Sitio del Tecnol&oacute;gico de Monterrey</a></li>
          <li><a target="_blank" href="http://academia.itesm.mx">Portal Acad&eacute;mico</a></li>
          <li><a target="_blank" href="http://alumnos.itesm.mx">Portal de Alumnos</a></li>
          <li><a target="_blank" href="http://www.ruv.itesm.mx/">Portal de Universidad Virtual</a></li>
          <li><a target="_blank" href="http://exatec.itesm.mx/">Portal de Egresados</a></li>
          <li><a target="_blank" href="http://www.tecmilenio.edu.mx">Sitio de la Universidad TecMilenio</a></li>
        </ul>
    </div>
    </td>
    </tr>
    </table>
     
    <div id="botnav" class="botnav">
        <ul class="botmenuLinks">      
          <li>&reg; <a target="_blank" href="http://www.itesm.edu/">Instituto Tecnol&oacute;gico y de Estudios Superiores de Monterrey</a>, M&eacute;xico. 2010</li>
          <li><a href="/screens/creditos.html"> |  Cr&eacute;ditos</a></li>
          <li><a target="_blank" href="/screens/Aviso_Legal.pdf"> |  Aviso Legal</a></li>
        </ul>
    </div>
    <!--End the bottom logo table-->
    <!-- end botlogo.html file -->
     
    </body>
    </html>
    <!--this is customized <screens/pverify_web.html>-->

    im not sure if is because the last form is a password field but it says METHOD POST that i assume that it just a form, im not sure if i have to authenticate something

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: URL Problem

    Is the problem that you expect your code to read a different page from the server than the page it is actually reading?

    Your code is doing a POST to an https site and is sending this data :name=---&code=---&pin=---

    I'm not sure how to communicate using the https protocol.

  5. #5
    Junior Member
    Join Date
    Jun 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: URL Problem

    Yes Norm, i want to access a page, i wanto to do something like: fill the forms and click submit (or enter) and read the next page..

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: URL Problem

    Look into if you need something different with the https protocol.