Salve,
devo effettuare un login in un sito attraverso l'applicazione java che sto scrivendo.
Gli oggetti che uso sono URL e URLConnectioin.
Riesco a collegarmi alla home del sito, una volta prelevato il cookie riesco a navigare in tutte le sotto pagine utilizzando appunto questo cookie altrimenti il server web si sarebbe preoccupato di reindirizzarmi di nuovo alla home.
Ora il mio problema è che se prova ad effettuare il login da un form, come risposta dal server mi trovo di nuovo la home page e in piu mi assegna un nuovo cookie. Il metodo che uso e quello POST anche perche visualizzando il codice sorgente della pagina questo è il metodo che bisogna usare per inviare i dati al server.
Vi posto il codice sorgente della pagina in cui devo effettuare il login, se avete qualche idea scrivetemi grazie.
i campi che invio sono:
family = studente
userid = "*****"
password = "*****"
e con il mio oggetto UrlConnection invoco la pagina :
https://didattica.unical.it/cosenza/...gonStudenti.do
----------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="Content-Language" content="it"/>
<meta name="Description" content="UNIQUE - Unimatica s.p.a. Framework"/>
<link rel="STYLESHEET" type="text/css" href="/cosenza/style/index_html-style.css"/>
<base href="https://didattica.unical.it/cosenza/prenotazione/studente/" />
<meta name="Author" content="Ing.Michele Mogioni">
<meta name="Author" content="Anna Chiara Bellini">
<meta name="Author" content="Christophe Thi?baud">
<title>UNIWEX logon studente</title>
<script type="text/javascript">
//<![CDATA[
var startLoadTime = new Date() ;
var pageLoadTimeMilli = 0 ;
var AppletObjectName ="PKIWrap" ;
var isW3C = true ;
var isIE4p = false ;
var isNN4 = false ;
var isNN6 = true ;
var isW3CDOM = true ;
var isIE4pDOM = false ;
var isNN4DOM = false ;
var isNN6DOM = true ;
var useDownImage = false ;
var Doc ;
var Frm ;
var LastErr ;
var Working = 1 ;
var LoadingApplet = 0 ;
var JSIs_InSubmit = 1 ;
var IMG_ApplLoading = new Image ;
var IMG_PageLoading = new Image ;
IMG_PageLoading.src = "/cosenza/unique/img/it/loading.gif" ;
function getNamedItems ( MsgName )
{
return document.getElementsByName(MsgName) ;
}
//---
function getNamedItem ( MsgName , Idx )
{
var colle ;
colle = getNamedItems( MsgName ) ;
if ( ( colle != null ) && ( colle.length != null ) && ( colle.length > Idx ) ) return colle[idx] ;
return null ;
}
function DocumentRecalc ( )
{
}
if ( document.all )
Doc = document.all ;
else {
Doc = document ;
Node.prototype.__defineGetter__ ( "all" , function() {
if ( document.getElementsByTagName("*").length)
{
switch(this.nodeType)
{
case 9 :
return document.getElementsByTagName("*") ;
case 1 :
return this.getElementsByTagName("*");
}
}
return "" ;
} ) ;
Node.prototype.__defineSetter__("all",function() {} ) ;
}
IMG_ApplLoading.src = "/cosenza/unique/img/it/underConstructionJava.gif" ;
var IMG_Array = new Array() ;
function PldButtonImg ( ImgPath , ImgID )
{
if ( IMG_Array[ImgID] != null ) return ;
IMG_Array[ImgID] = new Image() ;
IMG_Array[ImgID].src = ImgPath + ".gif" ;
IMG_Array[ImgID+"_over"] = new Image() ;
IMG_Array[ImgID+"_over"].src = ImgPath + "_over.gif" ;
IMG_Array[ImgID+"_dis"] = new Image() ;
IMG_Array[ImgID+"_dis"].src = ImgPath + "_dis.gif" ;
}
//---
function StopEvent ( evt )
{
if ( evt == null ) evt = event ;
if ( evt.returnValue != null ) evt.returnValue = false ;
return ( false ) ;
}
//---
//---
function WindowNavigate ( hRef )
{
location.assign( hRef ) ; // Check Method !!!
}
//---
//---------
function LinkAppletPlugin ( AplName )
{
var Wrap ;
Wrap = document.getElementById(AplName) ;
return Wrap ;
if ( ( Wrap != null ) && ( Wrap.readyState != null ) )
{
St = Wrap.readyState ;
if ( ( St == "complete" ) || ( St == 4 ) ) return ( Wrap ) ;
}
return ( null ) ;
}
//]]>
</script>
<script type="text/javascript" src="https://didattica.unical.it/cosenza/unicore/js/JavaScriptBase.js" > </script>
<script type="text/javascript" src="https://didattica.unical.it/cosenza/unique/js/RefactoredFunctions.js" > </script>
<script type="text/javascript">
//<![CDATA[
// sostituita da JavaScriptBase.clearHTML(objectId)
// function ClearMsgs ( MsgName )
// {
// setInnerHTML(MsgName, "");
// }
function MeasureLoadTime()
{
if ( pageLoadTimeMilli == 0 )
{
var d = new Date() ;
pageLoadTimeMilli = d.getTime() - startLoadTime.getTime() ;
}
return pageLoadTimeMilli ;
}
function PageBodyLoaded()
{
MeasureLoadTime() ;
window.status = "Caricamento pagina completato, potete lavorare";
clearHTML("MessagePageLoading");
// ClearMsgs ( "MessageAppletLoading" ) ;
OtherOnLoad() ;
JSIs_InSubmit = Working = 0 ;
}
//---------
var DoOnLoad = new Array(0) ;
//---------
function OtherOnLoad()
{
var i ;
if ( ( DoOnLoad == null ) || ( DoOnLoad.length == null ) ) return ;
for ( i = 0 ; i < DoOnLoad.length ; i++ )
{
eval(DoOnLoad[i]);
}
}
//---------
function AddOnLoadFunction( strFunz )
{
DoOnLoad.push(strFunz) ;
}
//]]>
</script>
</head>
<body id="uniqueBody" onload="PageBodyLoaded();" >
<div id="MessagePageLoading">
<div id="MessagePageLoadingContent">
<table class="MessagePageLoadingContentBox">
<tr>
<td class="MessagePageLoadingLeft">[img]/cosenza/unique/img/it/loading.gif[/img]</td>
<td width="*" class="MessagePageLoadingCenter" align="center">
<big>Caricamento pagina in corso
... Attendere, prego ...</big>
</td>
<td class="MessagePageLoadingRight">
[img]/cosenza/unique/img/it/loading.gif[/img]
</td>
</tr>
</table>
</div>
</div>
<table cellspacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td colspan="3" height="10"></td>
</tr>
<tr>
<td colspan="3" height="192" align="right" background="/cosenza/login/img/home_bgtab01.gif" >
[img]/cosenza/login/loghi/logo_01_cosenza_it.gif[/img]</td>
</tr>
<tr>
<td></td>
<td width="462" valign="top">
[img]/cosenza/login/loghi/logo_02_cosenza.gif[/img]
<div align="center">
[img]/cosenza/login/loghi/logo_uniwex.gif[/img]
</div>
</td>
<td width="260">
<table cellPadding=10>
<tr>
<td>
<table cellSpacing=0 cellPadding=0 height="100%" width="100%" class="unique">
<form name="uniqueLogonForm" method="post" action="/cosenza/unique/uniqueLogonStudenti.do">
<input type="hidden" name="family" value="studente" />
<tr class="unique">
<td align="right" class="unique">
<span class="uniqueLabel" >
User ID
</span>
</td>
<td align="left" class="unique">
<span class="uniqueInput" >
<input type="text" name="userid" maxlength="64" size="14" value="" />
</span>
</td>
<td align="left" class="unique">
<span class="uniqueError" >
</span>
</td>
</tr>
<tr class="unique">
<td align="right" class="unique">
<span class="uniqueLabel" >
Password
</span>
</td>
<td align="left" class="unique">
<span class="uniqueInput" >
<input type="password" name="password" maxlength="255" size="14" value="" />
</span>
</td>
<td align="left" class="unique">
<span class="uniqueError" >
</span>
</td>
</tr>
<tr class="unique">
<td align="right" class="unique">
</td>
<td colspan="2" class="unique">
</td>
</tr>
<tr class="unique">
<td align="left" colspan="3" nowrap="nowrap" class="unique">
<script type="text/javascript">
//<![CDATA[
PldButtonImg ( "/cosenza/core/img/it/accedi" , "accedi" );
//]]>
</script>
<input type="image" id="IMGTAGauto_1" name="IMGTAGauto_1"
onmouseover = "ChButtonImg( this , 'accedi' , '_over' )"
onmouseout = "ChButtonImg( this , 'accedi' , '' )"
onclick="StopEvent( event );DoSubmitByName( 'uniqueLogonForm' ) ; return(false)"
src="/cosenza/core/img/it/accedi.gif" title="accedi" alt="accedi" />
<script type="text/javascript">
//<![CDATA[
PldButtonImg ( "/cosenza/core/img/it/annulla" , "annulla" );
//]]>
</script>
<input type="image" id="IMGTAGauto_2" name="IMGTAGauto_2"
onmouseover = "ChButtonImg( this , 'annulla' , '_over' )"
onmouseout = "ChButtonImg( this , 'annulla' , '' )"
onclick="return ( ClickHref('/cosenza/unique/uniqueStopLogon.do' , event ) )"
src="/cosenza/core/img/it/annulla.gif" title="annulla" alt="annulla" />
</td>
</tr>
</form>
<script type="text/javascript">
var focusControl = document.forms["uniqueLogonForm"].elements["userid"];
if (focusControl.type != "hidden") {
focusControl.focus();
}
</script>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td></td>
<td width="462" valign="top">
<ul>
[*]<font style="color:#c00000"> User ID </font> : il proprio numero di matricola completo.
[*]<font style="color:#c00000"> Password </font> : il proprio PIN (Personal Identification Number) (8 cifre). Se non si fosse in possesso del PIN è possibile richiederlo all'indirizzo http://sos.unical.it
ATTENZIONE: SI RICORDA CHE DALLA DATA DI PRIMA RICHIESTA DEL PIN DEVE PASSARE UN GIORNO PRIMA CHE IL PIN SIA EFFETTIVAMENTE ATTIVO.
AVVISO IMPORTANTE: per i soli studenti iscritti ai corsi di laurea che hanno aderito alla firma forte (eleiminando di fatto lo statino cartaceo) è necessario prendere visione degli esami registrati dai propri docenti mediante la funzione "presa visione verbali" apponendo il proprio PIN Uniwex per il passaggio degli esami stessi in Segreteria Studenti. Questa funzione non è necessaria per studenti iscritti ad altri corsi di laurea.
[/list]
</td>
<td width="260">
<div align="center">
[img]/cosenza/login/loghi//logo_cineca.gif[/img]
</div>
</td>
</tr>
</table>
</body>
</html>