Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Servlets & <strong>Server</strong>s<br />
on that URL<br />
URL url = new URL(TARGET_URL);<br />
HttpURLConnection con = (HttpURLConnection) url.openConnection();<br />
// Indicate that you will be doing input and output, that the method is POST, and that<br />
the content<br />
// length is the length of the byte array<br />
con.setDoOutput(true);<br />
con.setDoInput(true);<br />
con.setRequestMethod("POST");<br />
con.setRequestProperty("Content-length", String.valueOf(bytes.length));<br />
// Write the parameters to the URL output stream<br />
OutputStream out = con.getOutputStream();<br />
out.write(bytes);<br />
out.flush();<br />
// Read the response<br />
BufferedReader in = new BufferedReader(<br />
new InputStreamReader(con.getInputStream()));<br />
while (true) {<br />
String line = in.readLine();<br />
if (line == null) break;<br />
System.out.println(line);<br />
}<br />
in.close();<br />
out.close();<br />
con.disconnect();<br />
--<br />
Phil Hanna<br />
Author of Instant <strong>Java</strong> Servlets<br />
http://www.philhanna.com<br />
I am writing an application, using <strong>Java</strong> Servlets, which requires me to set and<br />
read cookies. It works okay, but fails if I set the domain of the cookie to something<br />
other than the current server.<br />
I am writing an application, using <strong>Java</strong> Servlets, which requires me to set and read<br />
cookies.<br />
Using the servlet API, and the javax.servlet.http.Cookie class.<br />
I created a new cookie, and added it to the http response, using its addCookie()<br />
method. It works okay, but fails if I use the setDomain method, on the newly created<br />
cookie, to set the domain of the cookie to something other than the current server.<br />
Answer: I suspect that is not a legal operation for any browser to<br />
accept a cookie that has a domain inconsistent with the source<br />
of the cookie.<br />
by William Brogden<br />
I am working on weblogic server 5.1 with MsSQLSERVER7 i am able to load the<br />
driver but it says unable to get socket connection<br />
file:///F|/350_t/350_tips/servlets_servers.htm (4 of 8) [2002-02-27 21:19:05]