Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Community > Forum De Bell Tolls > [Java] help
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
pancio23
.novellino.

User info:
Registered: Dec 2002
Posts: 3 (0.00 al dì)
Location: Valbrona (CO)
Corso: Informatica
Anno: 3° f.c.
Time Online: 2:05:43 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Java

Qualcuno sa come fare per catturare i messaggi di risposta del browser quando carica un URL.

Come Page not found, ecc.

Io lancio il browser da java usando la classe "Browser" che contiene il metodo "displayURL(string URL)".

A questo punto vorrei sapere se il browser carica la pagina o meno!

Grazie

__________________
:ihihih:

01-11-2004 15:56
Click Here to See the Profile for pancio23 Click here to Send pancio23 a Private Message Find more posts by pancio23 Add pancio23 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.84 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:57:33 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

potresti essere mooolto più chiaro?
magari posta anche il codice che usi (fra i tag "code" cosi non si spagina tutto)...

__________________
http://www.twitter.com/0m4r

01-11-2004 16:12
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
pancio23
.novellino.

User info:
Registered: Dec 2002
Posts: 3 (0.00 al dì)
Location: Valbrona (CO)
Corso: Informatica
Anno: 3° f.c.
Time Online: 2:05:43 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
[Java] Help

Bè, il codice dell'evento che lancio per aprire il browser è :

class ButtonListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
String URL = e.getActionCommand();

try {
b.init();
b.displayURL(URL);
}
catch (Exception exc) {
JButton button = (JButton)e.getSource();
button.setEnabled(false);
System.err.println(exc.getMessage());
}
}
}

Dove URL è una stringa. A questo punto il browser si apre correttamente, ma io salvare da qualche parte la risposta del browser : ossia se l'url è stato caricato correttamente o se ha incontrato qualche errore.

__________________
:ihihih:

01-11-2004 16:24
Click Here to See the Profile for pancio23 Click here to Send pancio23 a Private Message Find more posts by pancio23 Add pancio23 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
0m4r
.grande:maestro.

User info:
Registered: Mar 2002
Posts: 7287 (0.84 al dì)
Location: Düsseldorf (DE)
Corso:
Anno: ESAMI FINITI
Time Online: 49 Days, 0:57:33 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Lightbulb

code:
class ButtonListener implements ActionListener { public void actionPerformed(ActionEvent e) { String URL = e.getActionCommand(); try { b.init(); b.displayURL(URL); }catch (Exception exc) { JButton button = (JButton)e.getSource(); button.setEnabled(false); System.err.println(exc.getMessage()); } } }


scusa, ma cosa è b?
è un istanza della classe Browser (che poi, tra l'altro, sta classe Browser dove l'hai pescata?)

P.S.
dai un occhiata qui, qua e piu in generale a questo link

__________________
http://www.twitter.com/0m4r

Last edited by 0m4r on 01-11-2004 at 17:14

01-11-2004 17:06
Click Here to See the Profile for 0m4r Click Here to See the Blog of 0m4r Click here to Send 0m4r a Private Message Find more posts by 0m4r Add 0m4r to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
pancio23
.novellino.

User info:
Registered: Dec 2002
Posts: 3 (0.00 al dì)
Location: Valbrona (CO)
Corso: Informatica
Anno: 3° f.c.
Time Online: 2:05:43 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
[Java] Help

Ciao, innanzi tutto ti ringrazio, e mi scuso per il tempo che ti faccio perdere!

Purtroppo i link che mi hai mandato, li avevo già visitati, e in generale parlano di come aprire un browser usando java, ma non di come fare per catturare i messaggi di risposta del browser.

In poche parole, io devo passare una serie di url al browser e vedere se me li carica. Il tutto perchè devo fare un benchmarking dei filtri dei contenuti, come DAVIDE.IT o CHILDKEY.

Se trovi qualcosa d'altro te ne sarei grato, io non riesco ad inventarmi niente.

Ciao

__________________
:ihihih:

02-11-2004 14:35
Click Here to See the Profile for pancio23 Click here to Send pancio23 a Private Message Find more posts by pancio23 Add pancio23 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
ripe
- up in the mountains -

User info:
Registered: Jun 2002
Posts: 9469 (1.10 al dì)
Location: Cinisellooo
Corso: TICO TICO
Anno: Primo
Time Online: 61 Days, 2:33:39 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ho capito cosa intendi, ma ti so solamente dare la soluzione in Asp.Net (vista la grande somiglianza con Java, magari ti può essere d'aiuto lo stesso...):

Dim Richiesta As System.Net.HttpWebResponse
Dim Risposta As System.Net.HttpWebResponse
Dim Flusso As System.IO.StreamReader
Dim Pagina As String = "http://www.yoursite.com/prova.htm"
Dim Dati As String

Richiesta = Richiesta.Create(Pagina)
Richiesta.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)"

Risposta = Richiesta.GetResponse()
Flusso = New System.IO.StreamReader(Risposta.GetResponseStream())

Dati = Flusso.ReadToEnd
Flusso.Close()
Risposta.Close()

Response.Write("Pagina ottenuta in risposta: " & Risposta.ResponseUri.AbsoluteUri)

Response.Write("Meta tag: " & System.Text.RegularExpressions.Regex.Match(Dati, "URL=(?<href>[^""]+)""").Groups("href").Value()

Response.Write("Titolo della pagina: " & System.Text.RegularExpressions.Regex.Match(Dati, "<title>(?<title>[^<]+)</title>", System.Text.RegularExpressions.RegexOptions.IgnoreCase).Groups("title").Value

In questo modo posso analizzare se nei meta tag è previsto un redirect (ovvero l'indirizzo della pagina è cambiato) oppure se nel titolo è presente il famigerato 404! Lo so che non è un metodo affidabile nel 100% dei casi, ma per quello che serve a me è perfetto!

Vedi se riesci a convertire gli oggetti WebRequest e WebResponse nei rispettivi oggetti di Java...

__________________
«And if you ever smell christian blood up in the mountains, then get your axe and chop them down!»

02-11-2004 15:12
Click Here to See the Profile for ripe Click Here to See the Blog of ripe Click here to Send ripe a Private Message Find more posts by ripe Add ripe to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 14:32.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.152 seconds (51.55% PHP - 48.45% MySQL) con 25 query.