Theo,
Does the servlet take any input parameters from a Http POST or GET
request? By default, URLConnection is set up to do a GET request. You can
supply the parameters and values as part of the URL in the query
string. If your servlet expects posted data, you will need to call the
setDoOutput(true) method on the connection and then output the parameter
values to the output stream of the connection (once they have been
URLEncoded) and then close the output stream.
ie. From (Core Java Vol. II pg 177)
URL url = new URL("http://your host script");
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
// If you are sending text (simulating a browser) it is convenient to use a
PrintWriter
PrintWriter out = new PrintWriter(connection.getOutputStream());
// send the data to the server
out.print("var_1=" + URLEncoder.encode(val1) + "&");
out.print("var_2=" + URLEncoder.encode(val2) + "&");
.
.
out.print("var_n=" + URLEncoder.encode(val_n) + "\n");
out.close();
// You can now read the response in the usual way
BufferedReader in = new
BufferedReader(newInputStreamReader(connection.getInputStream()));
String line;
While ((line = in.readLine()) != null)
{
// process line
}
Regards,
Richard
At 04:45 PM 8/23/01 +0200, you wrote:
>Hi Kevin,
>
>
> > Please don't misinterpret... I really was trying to clarify your question.
> > :-)
>
>That's all right. I just thought that I was asking something very stupid,
>according to your first reply! Anyway!
>
>Well my servlet do something and then represents the results in a browser
>using
>html.
>I just wanted to check the contents of this html for a particular word.
>How can I view the results, just say using URLConnection, or something
>similar.
> I've already tried the code you send me, which is in the tutorial, but
> with
>no results.
>I tried to connect to the server, which it worked. Then I tried to connect to
>the servelt to see the response of the servlet but this way, you can't do
>much.
>Is this possible? Maybe am doing something wrong.
>Could you please help?
>
>See you
>Theo
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html