🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.java
Article #593

Re: Jak applet moze wyslac dane do CGI scripta metoda POST

#593
From: Paweł Sołtysiak
Date: Sat, 17 May 1997 19:54
60 lines
2527 bytes

Adam Wojciechowski <adam@cs.put.poznan.pl> napisał(a) w artykule
<5lflih$kts$1@math.amu.edu.pl>...
>   Prosze o wyjasnienie w jaki sposob mozna z poziomu appleta wysylac
> do CGI scripta dane metoda POST. 
> 
>   W ksiazce Special Edition Using Java znalazlem nastepujacy przyklad:
> 
> URL reverseURL = new URL("http://www.javasoft.com/cgi-bin/backwards");
> URLConnection reverseConn = reverseURL.OpenConnection();
> 
> PrintStream output = new PrintStream(reverseConn.getOutputStream());
> DataInputStream input = new
> DataInputStream(reverseConn.getInputStream());
> 
> output.println("string=TextToReverse");
> String reversedText = input.readLine();
> 
>   Byc moze, ze popelniam jakies bledy, o ktorych nie wiem, ale nie
> chce mi to dzialac. Jesli ktos z Panstwa zna rozwiazanie tego problemu
> to prosze o kilka wskazowek i jesli to mozliwe proste przyklady
> ilustrujace ten mechanizm. 
> 
>     				Z gory dziekuje i pozdrawiam
> 
> 						  Adam
> 
> 

Czesc

Oto fragment oprogramowania, które działa:

			URL url = new URL("http://host/cgi-bin/cgi.exe");  // Prykładowo
oczywiście
			URLConnection url_con = url.openConnection();

// Brakowało prawdopodobnie tego poniżej !!!, standardowo obiekt klasy
URLConnection jest // "nastawiony" na odbieranie
			url_con.setDoOutput(true);
			
                                    OutputStream cgi_out_str =
url_con.getOutputStream(); 
			PrintStream cgi_out_data = new PrintStream(cgi_out_str);

			cgi_out_data.println("Tekst pisany do CGI");
			cgi_out_data.close();

			InputStream cgi_in_str = url_con.getInputStream();
			DataInputStream cgi_in_data = new DataInputStream(cgi_in_str);

			b = cgi_in_data.readLine(); // Odczyt wyników 

Na marginesie, też miałem problemy, żeby otrzymać właściwą sekwencję
otwierania,pisania i czytania.

		Pozdrawiam

		Paweł Sołtysiak
Technical Details
Message-ID: <01bc62fc$bf949e40$ce02199d@soltys.com.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!news.icm.edu.pl!news.atm.com.pl!not-for-mail
References: <5lflih$kts$1@math.amu.edu.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!news.icm.edu.pl!news.atm.com.pl!not-for-mail
From: Paweł Sołtysiak <soltys@chemix.ch.pw.edu.pl>
Newsgroups: pl.comp.lang.java
Subject: Re: Jak applet moze wyslac dane do CGI scripta metoda POST
Date: 17 May 1997 19:54:42 GMT
Organization: KOMPAKT
Lines: 60
Message-ID: <01bc62fc$bf949e40$ce02199d@soltys.com.pl>
References: <5lflih$kts$1@math.amu.edu.pl>
NNTP-Posting-Host: dlp052.atm.com.pl
X-Newsreader: Microsoft Internet News 4.70.1157
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit