Hi guys, I need to refresh a page using meta refresh that redirects the page to a servlet. But I need to also capture in case user does not get the cookie on. I used both response.encodeURL() and response.encodeRedirectURL90 method to make sure the session ID is there. But, for some reason, the session ID does not get included in the refresh. Any idea? Thanks Rendra -----Original Message----- From: Nic Ferrier [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 10, 2001 10:39 AM To: [EMAIL PROTECTED] Subject: Re: setParameterName/Value for URLConnection ? >>> Mike Whittaker <[EMAIL PROTECTED]> 10-May-01 3:52:37 PM >>> >Question >How do you (presumably with URLConnection class) fill in >the parameter names & values with Java? >I imagined it would be something like the setRequestProperty >method. Do you somehow send it in the body with the >OutputStream? If so how? setRequestProperty() allows you to specify an HTTP request *header*. The values sent as POSTs are sent in the body of the POST. In order to POST the parameter "name" with the value "value" to a server we do the following: - get an HttpURLConnection: HttpURLConnection urlcon=new URL("http://host/res/").openConnection(); - set the URLConnection to allow output: urlcon.setDoOutput(true); - set the content type and method correctly: utlcon.setRequestMethod("POST"); urlcon.setRequestProperty("Content-Type","application/x-www-form-url-encoded "); - add the post body to the request: OutputStream out=urlcon.getOutputStream(); out.println(URLEncoder.encode("name") +"=" +URLEncoder.encode("value")); out.flush(); out.close(); It's unforunate that POSTs are not better supported by the API, they easily could be, but as you're probably beginning to understand: there are a lot of holes in java.net.URL classes. Nic Ferrier PS PLEASE change your reply-to - it's really annoying ___________________________________________________________________________ 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
