Results 1 to 20 of 27
Thread: Deleting Cookies in Java
- 05-20-2011, 04:13 AM #1
Senior Member
- Join Date
- Mar 2011
- Posts
- 261
- Rep Power
- 3
- 05-20-2011, 04:19 AM #2
I wonder if you can tell the server to clear your cookies. ???
My idea of how cookies work is that they are stored in your browser. When the browser connects to a server it sends all the cookies it has for that site. If you have saved any cookies from your previous connection to a site you could clear them and then send them to the site.
- 05-20-2011, 04:32 AM #3
Senior Member
- Join Date
- Mar 2011
- Posts
- 261
- Rep Power
- 3
- 05-20-2011, 01:48 PM #4
Look at the contents of a HTML request header. It contains the cookies that are being sent to the server.
I have no idea how your code would save cookies. Does it get cookies from the site when it connects for login?
Can you explain all of your app in more detail?
- 05-20-2011, 11:51 PM #5
Senior Member
- Join Date
- Mar 2011
- Posts
- 261
- Rep Power
- 3
- 05-20-2011, 11:53 PM #6
Sorry, I have no idea how the site you are using works.
- 05-21-2011, 12:00 AM #7
Senior Member
- Join Date
- Mar 2011
- Posts
- 261
- Rep Power
- 3
- 05-21-2011, 12:12 AM #8
Where would the URLConnection class get the cookie from if you are connecting for the first time?
Have you tried using the URLConnection methods to look at the contents of the header fields?
- 05-21-2011, 12:14 AM #9
Senior Member
- Join Date
- Mar 2011
- Posts
- 261
- Rep Power
- 3
- 05-21-2011, 12:15 AM #10
Does the URLConnection class send cookies when it connects to a server?
- 05-21-2011, 12:17 AM #11
Senior Member
- Join Date
- Mar 2011
- Posts
- 261
- Rep Power
- 3
- 05-21-2011, 12:21 AM #12
Do you have any software you can run to show what is sent and received?
How would URLConnection get any cookies to send on its first usage?
Here's what is sent by a simple program:
That's sent by this code:GET / HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; H010818)
Host: 127.0.0.1:8080
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-aliveJava Code:import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; public class GrabHTML { public static void Connect() throws Exception{ //Set URL URL url = new URL("http://127.0.0.1:8080"); // Connect to my server URLConnection spoof = url.openConnection(); //Spoof the connection so we look like a web browser spoof.setRequestProperty( "User-Agent", "Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; H010818)" ); BufferedReader in = new BufferedReader(new InputStreamReader(spoof.getInputStream())); String strLine = ""; //Loop through every line in the source while ((strLine = in.readLine()) != null){ //Prints each line to the console System.out.println(strLine); } System.out.println("End of page."); } public static void main(String[] args){ try{ //Calling the Connect method Connect(); }catch(Exception e){ } } }
- 05-21-2011, 12:25 AM #13
Senior Member
- Join Date
- Mar 2011
- Posts
- 261
- Rep Power
- 3
- 05-21-2011, 12:30 AM #14
I don't know how you can keep the server from sending a Set-Cookie header field.I just don't want to send or receive cookies at all.
You should be able NOT to send a Cookie header field.
- 05-22-2011, 01:50 AM #15
Senior Member
- Join Date
- Mar 2011
- Posts
- 261
- Rep Power
- 3
I know for a fact that the server sends cookies, I got their names and values.
How can I make it so my URLConnection doesn't save/send the cookies?
I've been trying to figure this out forever, thanks.
- 05-22-2011, 01:52 AM #16
Does URLConnection save/send cookies without you telling it to?How can I make it so my URLConnection doesn't save/send the cookies?
- 05-22-2011, 02:14 AM #17
Senior Member
- Join Date
- Mar 2011
- Posts
- 261
- Rep Power
- 3
- 05-22-2011, 02:34 AM #18
Not really. I find out things by trial and error and by looking at the stash of programs I've written over the years.
Why do you believe so? Do you have a small program that demonstrates it?
- 05-22-2011, 02:41 AM #19
Senior Member
- Join Date
- Mar 2011
- Posts
- 261
- Rep Power
- 3
- 05-22-2011, 02:44 AM #20
Similar Threads
-
Executing Command line commands from java - problem with deleting a file
By efebatistaarda in forum Advanced JavaReplies: 7Last Post: 02-10-2011, 07:37 PM -
Java: Handling cookies when logging in with POST
By cloakbot in forum New To JavaReplies: 1Last Post: 06-17-2010, 12:19 AM -
Logging in with Java (cookies)
By Supamagier in forum Advanced JavaReplies: 0Last Post: 05-15-2009, 10:22 AM -
Deleting and Adding Lists in Java Applets
By Bomber_Will in forum Java AppletsReplies: 4Last Post: 11-28-2008, 06:52 AM -
JSP cookies example
By Java Tip in forum Java TipReplies: 0Last Post: 01-15-2008, 03:11 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks