Java cookies problem

I have been writing a proxy server.
when client(web browser) send the request to the proxy server, the proxy server will parse the request, and access to the web server.
rmRequest is a class to parse the request.
URL u=new URL(rmRequest.url); // rmRequest is a class to parse the request.
HttpURLConnection conn = (HttpURLConnection) u.openConnection();
if there is cookies,
conn.setRequestProperty("Cookie",rmRequest.cookie);
will be added.
When the respond come back to proxy server, the proxy server will divert it to the web browser with InputStream.
The problem comes when I am trying to login to some web site.
I could POST the request with the content and getting back to the logged in page.
but the cookie is not saved to the web browser.
Which means when i click on any button later on, the GET request does not contain any cookie.
for example, i login to a forum.
after typing username and password, and click on the 'login'.
The web browser send a POST request to the proxy server and so does the proxy server to the webserver.
The webserver return the page with 'login successfully, welcome back!'.
but when i click on other link of the website, it return the login page and saying that i have not log in yet.
The web browser is not saving the cookie after logging in to the forum!
I wonder how could I get the cookie and ask the web browser to set the cookie for the logged in website.

If you are going to use "second" method then you should take care about all HTTP staff. Cookies' basics are easy - just look for "Set-Cookie" strings within server answer and remember specified cookies for future use.

Similar Messages

  • Can't load Netflix - Firefox says something about cookie problem and recommends try again button. ("The page isn't redirecting properly Firefox has detected tha

    Can't load Netflix - Firefox says something about cookie problem and recommends try again button. ("The page isn't redirecting properly Firefox has detected that the server is redirecting the request for this address in a way that will never complete. This problem can sometimes be caused by disabling or refusing to accept cookies.)" Hit the try again button repeated ly - nothing???

    I decided to give Netflix a call about this problem.
    On a recording while waiting for a support rep, it said if you're having problems logging in to go to:
    http://www.netflix.com/clearcookies
    It works for me. Now I have to logon everytime I go to their site though versus it had kept me already logged in before this problem.
    I will be using that link to get to their site until they get it fixed.

  • Java Session problem while sending mail(using javamail) using Pl/SQL

    Hello ...
    i am using Java stored procedure to send mail. but i'm getting java session problem. means only once i can execute that procedure
    pls any help.

    props.put("smtp.gmail.com",host);I doubt javamail recognizes the 'smtp.gmail.com' property. I think it expects 'mail.host'. Of course since it cannot find a specified howt it assumes by default localhost
    Please format your code when you post the next time, there is a nice 'code' button above the post area.
    Mike

  • Java Programming Problem

    Hi all,
    I was looking for this java programming problem which had to do with a large building and there was some gallons of water involved in it too somehow and we had to figure out the height of the buiding using java. This problem is also in one of the java books and I really need to find out all details about this problem and the solution. NEED HELP!!
    Thanks
    mac

    Yes, it will. The water will drain from the bottom of
    the tank until the pressure from the water inside the
    tank equals the pressure from the pipe. In other
    words, without a pump, the water will drain out until
    there is the same amount of water in the tank as in
    the pipe The water pressure depends on the depth of the water, not the volume. So once the depth of the water inside the pipe reaches the same depth as the water inside the tank it will stop flowing. This will never be above the height of the tank.
    I found this applet which demonstrates our problem. If you run it you can drag the guy up to the top, when water in his hose reaches the level of the water in the tank it will stop flowing out.

  • Java Uninstall Problem

    Java Uninstall Problem
    This all came about because of a failed uninstall, using Your Uninstaller.
    The {Java runtime which is all I want) is not listed now & I tried all the other fix bad uninstall type features, all to no avail.} )
    When I DL & run the latest package (jxpiinstall-6u11-fcs-bin-b90-windows-i586-25_nov_2008.exe}
    & run it I get:
    1st message:
         "This software has already been installed on your computer.
         Would you like to install it?"
    If I say no, it exits.
    If I say yes, I get this second message:
         :This action is only valid for products that are currently installed."
    So Now I have no Java & have no idea what to do.
    Any help would be greatly appreciated.
    Thanks, Neuromancer23

    Sorry...after posting it i realized there was a more appropriate forum, of which it took quiet awhile to find.)
    Now that I know where to find the forum list I will never double-post again.
    I'll close the question if I can

  • Cookie problem in APEX 4.1.1

    After upgrading from APEX 4.1 to 4.1.1 the first time a user visits a particular application they see a line at the top of the page of the form:
    "Set-Cookie: PUBLIC_WWV_CUSTOM-F_1047528391177278_666=1316663583787701; HttpOnly "
    As soon as they refresh the page, the text disappears. I believe this is related to the issue of larger cookie sizes in 4.1.1 that a lot of people seem to be experiencing with NTLM authenthication. However, this is occuring at the login page prior to authentication. There is an application process with a processing point of "On New Instance (new session)" with the following code to create a cookie:
    owa_util.mime_header('text/html', FALSE);
    owa_cookie.send(
    name => 'PPP_SESSSION',
    value => to_char(v('APP_SESSION')),
    domain => '.dooda.com',
    path => '/');
    owa_util.http_header_close;
    As soon as I remove that process, the issue goes away. Of course that raises more troublesome issues. :)
    The workaround for the NTLM/cookie problem doesn't seem applicable here. Does anyone have any suggestions?
    Am I leaving out any helpful information? (I'm not so familiar with APEX and I don't know jack about web development).
    Thanks for any help.
    Chris

    Chris,
    This is a little bit of a guess here, but can you try removing the line:
    owa_util.http_header_close;
    from your On New Instance process?
    What appears to be happening is APEX is attempting to write the session cookie, but the HTTP headers have already been closed.
    Joel

  • Sun Java security problems

    Please any one tel me about Sun Java security problems
    with Desktop application

    Hi.
    If you're using SSGD 4.41, please download the Admin guide from here:
    http://docs.sun.com/app/docs/doc/820-4907
    There, at page #41 you'll find useful info concerning "Client Connections and Security Warnings".
    Hope this helps,
    Rob

  • Cookies problem

    hi..
    i have a cookie problem in my jsp page..everytime it causing problem...if the file is not in existence it displays it contents...
    i have a jsp page with servlets...
    help me

    i still fail to see why you call it a cookie problem.
    Make sure the jsp result is not cached in your browser or firewall.
    Try redeploying your entire web-app.

  • Cookie problem with this forum?

    Today I am no longer able to connect with this forum with my Safari browser. All I receive in a page with the 6 categories and nothing else. Also, I am not able to log in. However, I can log in using Foxfire with all the topics correctly displayed. I suspect it must be a cookie problem and if that is so, I'm not sure where to go in Safari to delete cookies.

    Same problem is back after only one day. When using Safari (latest version), if I click on the following link...
    http://discussions.apple.com/category.jspa?categoryID=218
    All I see is the Category headings (no latest posts) and I'm NOT automatically signed in. When I attempt to sign in, I then go the the "new user" data page. After signing in, I get very restrictive access to the forum.
    When I sign in with Firefox, everything is normal. Yesterday when I had this problem, I erases the cookies from Safari and everything returned to normal. I hate to have to erase my cookies everyday to get access here as I prefer to use Safari.
    Is this happening to anyone else?

  • OS X Lion - JAVA SCRIPT PROBLEM

    I recently updated from Snow Leopard to OS X Lion. Now I seem to have a JAVA Script problem. Where do I start fixing this issue. I have checked updates etc etc but it seems to be updated. However, when I login to my web site backend, I have a problem. Any advice please?

    Would you please write some more details? explain the problem and what web site backend you use. Thanks.

  • Cookie problem using safari

    Hi all!
    I seem to have a cookie problem on Safari on my iPhone. This makes that it's very difficult for me to Ise forums, Google Reader, etc. I tried all three settings but apparently Safari doesn't store my cookies.
    Anybody else have this problem? I'm using firmware 1.1.4.
    Thanks,
    Ton.

    The first step you should take is a reset of the phone to potentially clear up the problem. To do this, hold the home button and the top button simultaneously until you see the apple logo. If this doesn't cure the problem, a restore is in order, and this can be accomplished from iTunes. First try a restore from backup. If this doesn't work, you can do a restore to factory from iTunes, which should clear up the problem if the prior steps haven't worked.

  • "Java enabled" - "accept cookies"  PROBLEMS

    Just today I ran accross 2 big problems:
    1. A discuission group I regularly post to won't allow me too as it says "Java must be enabled to post" - it IS enabled in my prefs?!?
    2. A secure commerce I've logged into before told me "must be set to accept cookies" - again, it IS in my prefs.
    All I've done to try and fix, is restart.
    My version is: OS X 10.2.8, Safari 1.0.3

    I am having the same probem with the "must be set to accept cookies". I get the message when I try to log onto a secure banking site. Firefox works fine. Anything I can do to remedy? I emptied cache, deleted cookies from site, and emptied the icons folder.
    One more thing I should add. When I registered for the site originally, I was able to log on and view my account, but only that one time. Now i get the cookies mssg when I enter my log and pass and hit "log in".
    Running Tiger and Safari 2.0.1 with all updates installed.
    Thanks

  • Problems enabling Java/cookies to work on firefox macbook pro

    I am running Firefox.   I've checked that Java is enabled and I have the latest update.  Yet it is only this one site that it keeps giving me the same message " enable java and cookes" to view site.    Is this the issue where firefox does this on sites it deems unsafe?  and if so how do I sort it out.  Up until 2 days ago I was able to access this site without any issues like this.  This is on my macbook pro.  I went into system setting and found Java upload so it's there.  when I go into preferences on firefox though there is nothing at all about enabling cookies or java??   Should I revert back to Safari to stop this issue?
    Cheers

    As I said in your other post this is the iPod touch forum. Post in the MacBook Pro or OSX forum

  • IE 6.0 Cookies Problem

    I am trying to use iSQL*Plus with Microsoft Internet Explorer 6.0. I can sign on just fine, but every time I try to run a query, I get the following error:
    SP2-0915 Cookies may have been disabled
    iSQL*Plus works fine with my old Netscape 4.72, but I would really like to make it work with IE 6.0.
    I have gone to the Tools, Internet Options, Privacy and set it to "Accept All Cookies". No luck.
    Does anyone have any Ideas?

    Thanks for trying, but still no luck. I have 5 PCs on my network at home. Two are XP machines and 3 run Win 98. iSQL*plus works using Netscape and fails using IE 6.0 on all 5 machines.
    I sign on to the HR database, and I get into the iSQL*Plus screen just fine. I then type:
    SELECT * FROM employees;
    I click on execute and I get the following:
    SP2-0915: Cookies may have been disabled
    I then went to the Tools - Internet Options - Security tab and set security to "Low" for the Internet Zone, Local Intranet Zone and Trusted Sites. On Trusted Sites, I clicked the Sites button and added the URL for iSQL*Plus to the list of trusted sites.
    I closed IE and reopened it. I checked to verify that all my changes had "taken". I logged into HR. No luck. Same problem.
    I logged into Scott/Tiger. I tried "Select * FROM EMP". No luck. Same problem.
    I disabled my antivirus software (McAffe). No luck. Same problem.
    Is there possibly some Java setting that I have messed up?
    Randy

  • HttpURLConnection & cookie problem

    Hi,
    Well I did have the solution to my problem a few days ago, but it seems that I somehow didn't save the changes to my code.
    I'm wanting to log into a website and download some customer information. Upon logging in, the login page sends cookies. Basically, I collect the cookies and go to the main page which requires another username and password which the login pages sends. The new username/password & cookies then needs to be sent to another page to login. Hopefully, you understand; otherwise, I'll attempt to expalain again.
    import javax.swing.*;
    import java.net.*;
    import java.io.*;
    public class test
         public static void main( String args[] )
              try
                   URL url = new URL("http://www.somesite.com/authenticate.asp");
                   HttpURLConnection connection = (HttpURLConnection)url.openConnection();
                   connection.setRequestMethod("POST");
                   connection.setInstanceFollowRedirects( true );
                   connection.setDoOutput( true );
                   connection.setDoInput( true );
                   connection.setFollowRedirects( true );
                   connection.setUseCaches( true );
                   connection.setRequestProperty( "Content-Type","application/x-www-form-urlencoded" );
                   PrintWriter out = new PrintWriter(
                                            connection.getOutputStream());
                   out.println( "username=somename&password=somepassword" );
                   out.close();
                   System.out.println( "Response: " + connection.getResponseMessage() );
                   BufferedReader in = new BufferedReader(
                                  new InputStreamReader(
                                  connection.getInputStream()));
                   String inputLine;
                   while ((inputLine = in.readLine()) != null)
                       System.out.println(inputLine);
                   in.close();
                   System.out.println("");
                   int j = 7;
                   while( connection.getHeaderField(j) != null )
                        System.out.println("Header " + j + ": " + connection.getHeaderField(j) );
                        j++;
                   System.out.println("URL: " + connection.getURL().toString() );
                   String cookie = connection.getHeaderField("set-cookie");
                   String firstcookie = "";
                   System.out.println("Cookie: " + cookie);
                   if(cookie!=null)
                        int index = cookie.indexOf(";");
                        if(index > 0)
                             firstcookie = cookie.substring(0, index);
                   System.out.println("Cookie1: " + firstcookie );
                   System.out.println("");
                   url = new URL("http://www.somesite.com/main.asp");
                   connection = (HttpURLConnection)url.openConnection();
                   connection.setUseCaches( true );
                   connection.setRequestMethod("POST");
                   connection.setInstanceFollowRedirects( true );
                   connection.setDoOutput( true );
                   connection.setDoInput( true );
                   connection.setFollowRedirects( true );
                   System.out.println("Cookies Test: " + firstcookie);
                   connection.setRequestProperty( "Content-Type","application/x-www-form-urlencoded" );
                   connection.setRequestProperty("Cookie", firstcookie);
                   out = new PrintWriter(
                                            connection.getOutputStream());
                   out.println("UserID=someusername&password=somepassword&andotherparameters...");
                   out.close();
                   System.out.println( "Response: " + connection.getResponseMessage() );
                   in = new BufferedReader(
                                  new InputStreamReader(
                                  connection.getInputStream()));
                   while ((inputLine = in.readLine()) != null)
                       System.out.println(inputLine);
                   j = 0;
                   while( connection.getHeaderField(j) != null )
                        System.out.println("Header " + j + ": " + connection.getHeaderField(j) );
                        j++;
                   System.out.println("\nURL: " + connection.getURL().toString() );
                   System.out.println( "Response: " + connection.getResponseMessage() );
              catch( java.io.IOException s)
                   JOptionPane.showMessageDialog(null, "IO Exception!");
                   s.printStackTrace();     
    }In the first URL that I connect to, everything works fine. I log into the site, receive a new username & password and then the cookies data. In the next login (or attempt to go to the main page of the login), I'm having trouble. I send the cookies, but it sends me back to the login screen because obviously something i'm doing is incorrect. I think it's the problems with my cookies. I may be wrong.
    This may be difficult to read due to all the debug info I have coded.
    Thanks,
    GCS584
    P.S. I do apologize if this has been posted in the incorrect forum
    Like I said, I did have this working a couple of days ago, yet it fails now.

    Not sure why you would use a substring to send the cookie. I have this code sample to
    make a request to an asp page and send contiues request to that asp page within the
    session set the first time (session is done with cookies in asp).
    here is the asp page:
    <%
    if Session("mySession")="" then
         session("mySession")=1
    else
         session("mySession")=session("mySession")+1
    end if
    response.write(session("mySession") & vbcrlf)
    %>this is the java app
    import java.io.*;
    import java.net.*;
    public class app {
         public static void main(String args[]) {
              new app();
         public app() {
              String c = openURL(null);
              System.out.println("cookie is now: " + c);
              openURL(c);
              System.out.println("cookie is now: " + c);
              openURL(c);
              System.out.println("cookie is now: " + c);
              openURL(c);
              System.out.println("cookie is now: " + c);
              openURL(c);
              System.out.println("cookie is now: " + c);
              openURL(c);
              System.out.println("cookie is now: " + c);
         public String openURL(String cookieIn){
              String cookie = "";
              try {
                   // Create a URLConnection object for a URL
                   URL url = new URL("http://localhost/test.asp");
                   URLConnection conn= url.openConnection();
                   // set the cookie if needed
                   if(cookieIn!=null){
                        conn.setRequestProperty("Cookie", cookieIn);
                        conn.connect();
                   // Get all cookies from the server.
                   // Note: The first call to getHeaderFieldKey() will implicit send
                   // the HTTP request to the server.
                   for (int i = 0;; i++) {
                        String headerName = conn.getHeaderFieldKey(i);
                        String headerValue = conn.getHeaderField(i);
                        if (headerName == null && headerValue == null) {
                             // No more headers
                             break;
                        if ("Set-Cookie".equalsIgnoreCase(headerName)) {
                             // Parse cookie
                             cookie = headerValue;
                   InputStream in = conn.getInputStream();
                   byte b[] = new byte[2];
                   in.read(b);
                   System.out.println(new String(b));
              } catch (Exception e) {
                   e.printStackTrace();
              return cookie;
    }This should print out the same cookie and an increasing number.

Maybe you are looking for

  • Album Art works for most, but not all

    I was reading previous forums on the subject, but no clear answer was given.. The album art shows up fine in itunes and my library and works for most of my music on my ipod, but how come some album's art does appear? I have it set manually and select

  • Firefox won't close properly in Vista or Win7

    We (my wife and I) have been dealing with this issue for the last year. It's gotten to the point we are ready to migrate back to IE! Situation: Boot system open FF browser enjoy FF with its addon and browsing ease. leave FF on and leave for a couple

  • Stuck: can't re-install Panther, only 10.0.3

    OK, I've posted this also on iMac CRT. Here's a short story: Panther ran beautifully fore quite a while, then started to have kernel panics due to faulty RAM. I just replaced the 2 128 Mb sticks that were faulty with a brand new 512 from Crucial. But

  • Want to change the icon in iOS7 back to iOS6

    I update iOS7, but I don't prefer the icon's of iOS7. I want to use the icons in iOS6. What should I do?

  • My Aperture trash always says I have 494 versions there?  How do I get a clean trash bin???

    Everytime I go to empty the bin it says there are 494 versions being deleted and this cannot be undone.  I empty the trash... It should be zero but...I  throw one other version away... it says I still have 494 version plus one or two....  when the tr