Checking if for a cookie

I have tried everything from looping until I find a cookie: line in the http request header to going crazy, but I just can't figure out how to check if a cookie has been set by the server, if someone can offer some input, I would appreciate it. Here is the code:
import java.io.*;
import java.net.*;
import java.util.*;
class WebServer
    public static void main(String argv[]) throws Exception 
         String requestMessageLine;
         String fileName;
         ServerSocket listenSocket = new ServerSocket(6789);
         System.out.println("WebServer running...  Hold CTRL + C to exit the server.");
         int num = 0;
         String checkForCookie;
         while(true)
              Socket connectionSocket = listenSocket.accept();//keep connection alive
                BufferedReader inFromClient =
                 new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
               DataOutputStream outToClient =
                 new DataOutputStream(connectionSocket.getOutputStream());
               requestMessageLine = inFromClient.readLine();
               //check for cookies here
               StringTokenizer tokenizedLine =
                 new StringTokenizer(requestMessageLine);
               if (tokenizedLine.nextToken().equals("GET"))
                    fileName = tokenizedLine.nextToken();
                         if (fileName.startsWith("/") == true )
                         fileName  = fileName.substring(1);
                        try
                                 File file = new File(fileName);
                                    int numOfBytes = (int) file.length();
                                   FileInputStream inFile  = new FileInputStream (fileName);
                                   byte[] fileInBytes = new byte[numOfBytes];
                                   inFile.read(fileInBytes);
                                   outToClient.writeBytes("HTTP/1.0 200\r\n");     
                               outToClient.writeBytes("Set-Cookie: cookie="+String.valueOf(num++)+"\r\n");
                               outToClient.writeBytes("\r\n");
                                   outToClient.write(fileInBytes, 0, numOfBytes);
                                catch(FileNotFoundException e)
                                   outToClient.writeBytes("<html><body><h1>");
                                   outToClient.writeBytes(fileName + " not found");
                                   outToClient.writeBytes("</h1></body></html>");
         connectionSocket.close();
             }//end of first if statement
              else System.out.println("Bad Request Message");
          }//end of while loop
     }//end of main
}//end of class

I'm not sure about this, but it would be worth looking in to: Can you set a cookie in a non 200 OK response?
This would, generally speaking, seem to be a highly unusual situation.
If you telnet into port 80 of your localhost while your app is running, you can you manually send in a request, and see the exact response that's being sent back.
If the Set Cookie response is in there, then the next step is to look in the cookie cache of your browser.
My guess is that the browser is not honoring the cookie header in a non 200 response, though.
- K

Similar Messages

  • Check for disabled cookies

    I need to be able to check if cookies are enabled or disabled on the server side using JAVA. On the client side, it is easy to check for disabled cookies, but we need that functionality on the server side.

    It is a though one and not very easily accomplished.
    Conceptual idea on how to do it:
    Server sends page to user and gives it an cookie.
    The page contains generated unique URL's.
    As soon as the user clicks on a link. Assemble information from the user by checking incoming cookie and the URL. If the cookie does not exist or does not conform to the one sent for the unique URL, user has them disabled or fooling them via proxy-server of some sort.
    Voila - now you know if they got cookies enabled or not!
    Don't think there is another way. Some web servers do this by automatic to keep track of sessions and some don't. Check manual for your server.
    Pros:
    Seamless transition for cookie based servers
    Cons:
    Strange URL's for the user
    Might need URL rewriting for all code
    User must traverse one way or another through 2 pages
    Generated pages has to be used. Static HTML is a bit hard for this purpose.
    Regards,
    Peter Norell

  • Every time I TRY to start firefox 18-19 I get an error message : Firefox has stopped working - close the program and check online for a solution - or - close ..

    Every time I TRY to start firefox 18-19 I get an error message : "Firefox has stopped working" - "close the program and check online for a solution" - or - "close the program" this happens TWICE every time I try to start firefox. Eventually after a random number of tries firefox will start normaly. I am useing firefox 19.0.2 now bit I belive it started when I upgraded to firefox 18 but am not sure, it might have been when I upgraded to firefox 19 ... but it has been happening for a very long time and I cannot find any helpfule solutions online.
    I have tried a Clean reinstall but it did not help.

    Hello,
    '''Try Firefox Safe Mode''' to see if the problem goes away. Safe Mode is a troubleshooting mode, which disables most add-ons.
    ''(If you're not using it, switch to the Default theme.)''
    * You can open Firefox 4.0+ in Safe Mode by holding the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * Or open the Help menu and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''
    Thank you.

  • Every time I TRY to start firefox 18-19 I get an error message : Firefox has stopped working - close the program and check online for a solution - or - close th

    Every time I TRY to start firefox 18-19 I get an error message : "Firefox has stopped working" - "close the program and check online for a solution" - or - "close the program" this happens TWICE every time I try to start firefox. Eventually after a random number of tries firefox will start normaly. I am useing firefox 19.0.2 now bit I belive it started when I upgraded to firefox 18 but am not sure, it might have been when I upgraded to firefox 19 ... but it has been happening for a very long time and I cannot find any helpfule solutions online.

    Certain Firefox problems can be solved by performing a ''Clean reinstall''. This means you remove Firefox program files and then reinstall Firefox. Please follow these steps:
    '''Note:''' You might want to print these steps or view them in another browser.
    #Download the latest Desktop version of Firefox from http://www.mozilla.org and save the setup file to your computer.
    #After the download finishes, close all Firefox windows (click Exit from the Firefox or File menu).
    #Delete the Firefox installation folder, which is located in one of these locations, by default:
    #*'''Windows:'''
    #**C:\Program Files\Mozilla Firefox
    #**C:\Program Files (x86)\Mozilla Firefox
    #*'''Mac:''' Delete Firefox from the Applications folder.
    #*'''Linux:''' If you installed Firefox with the distro-based package manager, you should use the same way to uninstall it - see [[Installing Firefox on Linux]]. If you downloaded and installed the binary package from the [http://www.mozilla.org/firefox#desktop Firefox download page], simply remove the folder ''firefox'' in your home directory.
    #Now, go ahead and reinstall Firefox:
    ##Double-click the downloaded installation file and go through the steps of the installation wizard.
    ##Once the wizard is finished, choose to directly open Firefox after clicking the Finish button.
    Please report back to see if this helped you!

  • How do I remove a credit/debit card from my account? I ask because I currently have a VISA gift/debit card with 50 dollars on it, but the money has run out so I want to usea new card. Also, there is no 'None' check option for payment type on my account.

    How do I remove a credit/debit card from my account? I ask because I currently have a VISA gift/debit card with 50 dollars on it, but the money has run out so I want to usea new card. Also, there is no 'None' check option for payment type on my account.

    Depending on how you created your account, "None" may or may not be an option. I believe it has something to do with whether the account was made through an App Store request or the regular iTunes Store. For example, my account allows no card but my father's doesn't allow there to be no card.
    To change the card, go to your account settings and change the information to your new card, and hit save.

  • Check Box for each row in report -- all rows deleting when pressing DELETE

    Hello experts! I have set up a report with a check box for each row. When I click the DELETE button to delete the selected rows, every single one of the rows get deleted...even the ones that are not selected. I have my process point set to "On Submit - After computations and validations".
    This is my delete process (SHG is the table and SHG_ID is the primary key):
    FOR i in 1..HTMLDB_APPLICATION.G_F01.count
    LOOP
    DELETE FROM SHG
    WHERE SHG_ID = HTMLDB_APPLICATION.G_F01(i);
    END LOOP;
    Also, I've added to query in the region source this line:
    htmldb_item.checkbox(1, SHG_ID) del,
    Where does the "1" come into this? Not sure what I am doing wrong!
    Message was edited by:
    user477193
    Message was edited by:
    user477193

    The 1 (first argument to all the htmldb_item.* APIs) corresponds to the array number in htmldb_application.g_fNN. So 1 will populate array g_f01, 2 will populate g_f02 and so on.
    Your code seems fine, it should delete only the checked rows. Are you sure there is no other process on the page that might be deleting the rows? See if you can put up an example on htmldb.oracle.com

  • Errors with SharePoint Security Token Service: "The revocation function was unable to check revocation for the certificate"

    I'm getting these errors in the eventlog and ULS, "An operation failed because the following certificate has validation errors:\n\nSubject Name: CN=SharePoint Security Token Service, OU=SharePoint, O=Microsoft, C=US\nIssuer Name: CN=SharePoint Root
    Authority, OU=SharePoint, O=Microsoft, C=US\nThumbprint: <STS CERTIFICATE THUMBPRINT>\n\nErrors:\n\n RevocationStatusUnknown: The revocation function was unable to check revocation for the certificate."
    The errors point to the SharePoint Security Token Service as the issue ("The revocation function was unable to check revocation for the certificate") reported back by the Topology service.  This is apparent when executing a search, accessing
    the managed metadata service, issuing SPSite commands in Powershell, or anything that needs to run through the "SharePoint Web Services" site.  I've looked at the certificate assigned to that site and everything appears to be in order. 
    It would seem to me to be either an incorrect endpoint configuration (internally cached perhaps?) or related to security access for the configuration database (in order to validate the certificate root).
    What I’ve tried so far:
    I’ve been all over the certificate settings, both in the server store, and within SharePoint Token Service config.  Both appear to be configured correctly such that the root CAs can be validated.
    Re-entered the passwords for the application pool domain accounts to eliminate these as a potential cause.  I’ve also verified the service accounts reporting the error, do have access to the configuration database.
    Re-provisioned the STS service to see if that might clear out any cached issues and validated everything else according to this
    MS Tech note.
    So far nothing has worked.  Is there anything else I could be looking at that I've missed? (Full eventlog detail below)
    Log Name:      Application
    Source:        Microsoft-SharePoint Products-SharePoint Foundation
    Date:          2/20/2015 11:19:41 AM
    Event ID:      8311
    Task Category: Topology
    Level:         Error
    Keywords:      
    User:          <SP SERVICE ACCOUNT>
    Computer:      <SHAREPOINTSERVER>
    Description:
    An operation failed because the following certificate has validation errors:\n\nSubject Name: CN=SharePoint Security Token Service, OU=SharePoint, O=Microsoft, C=US\nIssuer Name: CN=SharePoint Root Authority, OU=SharePoint, O=Microsoft, C=US\nThumbprint: <STS
    CERT THUMBPRINT>\n\nErrors:\n\n RevocationStatusUnknown: The revocation function was unable to check revocation for the certificate.
    Event Xml:
    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
      <System>
        <Provider Name="Microsoft-SharePoint Products-SharePoint Foundation" Guid="{6FB7E0CD-52E7-47DD-997A-241563931FC2}" />
        <EventID>8311</EventID>
        <Version>14</Version>
        <Level>2</Level>
        <Task>13</Task>
        <Opcode>0</Opcode>
        <Keywords>0x4000000000000000</Keywords>
        <TimeCreated SystemTime="2015-02-20T17:19:41.213852500Z" />
        <EventRecordID>1611121</EventRecordID>
        <Correlation />
        <Execution ProcessID="10212" ThreadID="10328" />
        <Channel>Application</Channel>
        <Computer><SHAREPOINTSERVER></Computer>
        <Security UserID="<SP SERVICE ACCOUNT>" />
      </System>
      <EventData>
        <Data Name="string0">CN=SharePoint Security Token Service, OU=SharePoint, O=Microsoft, C=US</Data>
        <Data Name="string1">CN=SharePoint Root Authority, OU=SharePoint, O=Microsoft, C=US</Data>
        <Data Name="string2"><STS CERT THUMBPRINT></Data>
        <Data Name="string3">RevocationStatusUnknown: The revocation function was unable to check revocation for the certificate.
    </Data>
      </EventData>
    </Event>

    Hi Darren,
    This problem seems to occur when an administrator deletes the local trust relationship of the farm from the Security section of the Central Administration website
    In order to resolve this problem, the local trust relationship has to be created. This can be done by running the following PowerShell commands
    $rootCert = (Get-SPCertificateAuthority).RootCertificate
    New-SPTrustedRootAuthority -Name "localNew" -Certificate $rootCert
    After running the above commands, perform an IISReset on all servers in the farm.
    More information:
    http://support.microsoft.com/kb/2545744
    Best Regards,
    Wendy
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Wendy Li
    TechNet Community Support

  • My form has a list of yes or no questions.  I want to use either cheboxes or radio buttons.  I can't make it work.  When I check yes for one question, it marks all yes answers for all other questions.  If I mark some radio buttons to answer, it unmarks la

    My form has a list of yes or no questions.  I want to use either cheboxes or radio buttons.  Unfortunatly I can't make it work.  When I check yes for one question, it marks all yes answers for all other questions.  If I mark some radio buttons to answer, it unmarks later.  Need immediate help!!!

    Is it that you are using a PDF-based form? Did you copy and paste the Yes/No fields all the way down your form? If so, then all of the yes/no boxes are copies of each other and have the same name and properties in the PDF.
    For example, if you had:
         Question 1 and Question 1 Yes/No checkboxes
         Question 2 and Question 1 Yes/No checkboxes
         Question 3 and Question 1 Yes/No checkboxes
         Question 4 and Question 1 Yes/No checkboxes
    Then whatever answer you selected in Question 1 would populate down through the rest of the form.
    Changing the Yes/No field properties in questions two through four would eliminate the problem.
    I hope that helps,
    Brian

  • Post install checks failed for DBC file - Oracle App11.5.10.2 Linux  5.3

    Hi everybody,
    I tried Installing Oracle E-Business Suite 11.5.10.2 on Red Hat Enterprise Linux Server release 5.3
    The Post install checks failed for DBC file, HTTP, JSP and PHP. Apparently the DBC hadn’t been created. I had verified the log file, while executing adgendbc.sh, it throwing below error.
    Generating /jith/d01/oracle/appl/visappl/fnd/11.5.0/secure/prithvi.bangalore.bedford.local_vis.dbc
    DBC generation failed with exit code 127
    Generating /jith/d01/oracle/appl/visappl/fnd/11.5.0/secure/prithvi_vis.dbc
    DBC generation failed with exit code 127
    Updating Server Security Authentication
    Updating Server Security Authentication failed with exit code 127
    adgendbc.sh exiting with status 127
    ERRORCODE = 127 ERRORCODE_END
    .end std out.
    touch: error while loading shared libraries: librt.so.1: cannot open shared object file: No such file or directory
    sqlplus: error while loading shared libraries: libdl.so.2: cannot open shared object file: No such file or directory
    mkdir: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
    grep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
    sed: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
    /jith/d01/oracle/appl/viscomn/util/java/1.4/j2sdk1.4.2_04/bin/java: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
    cp: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
    /jith/d01/oracle/appl/viscomn/util/java/1.4/j2sdk1.4.2_04/bin/java: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
    cp: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
    /jith/d01/oracle/appl/viscomn/util/java/1.4/j2sdk1.4.2_04/bin/java: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
    cp: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
    /jith/d01/oracle/appl/viscomn/util/java/1.4/j2sdk1.4.2_04/bin/java: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
    /jith/d01/oracle/appl/viscomn/util/java/1.4/j2sdk1.4.2_04/bin/java: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
    .end err out.
    Thanks in advance.
    sreejith

    Welcome to the forums !
    Pl post EBS related question in the EBS forums at http://forums.oracle.com/forums/category.jspa?categoryID=3
    HTH
    Srini

  • Goods Movement Not allowed(XWAOK) check box - for SRM Reservations.

    Dear Experts,
    We are working on Extended Clasissc sceanrio however certain materails we are creating reservation switching from ECS to Classic Scenario. System is Creating Reservation successfully in backend but Goods movement reservation allowed (FIELD XWAOK) check box not checked only for SRM Reservations
    Please note that ECC reservations checking this checkbox automatically based on Configuration. Is there any setting we have to do in SRM to pass the check box value to ECC? or How Can i check what data is passing from SRM to ECC......
    Thanks
    Ravi

    Dear Ravi,
    Could you please check if you have added the value '201' against the attribute movement type (forgot the attribute name) for the purchasing group or user group who created the shopping cart in SAP SRM. Once you have added the attribute, the problem should be resolved.
    Thanks and regards,
    Ranjan

  • Bridge CC on opening gives "Adobe Bridge CC has stopped working" Uninstalled, re-installed same error, will not run. "check online for a solution" does nothing.

    Bridge CC on opening gives "Adobe Bridge CC has stopped working" Uninstalled, re-installed same error, will not run. "check online for a solution" does nothing.
    Bridge worked great for a while then started to fail when starting. Old Bridge CS6 still works fine. HELP ... please.

    You problem is in the Fault Module MSVCR80.dll
    Do a web search for this.  Here is one LINK

  • What is the correct firmware update check URL for a Westell VersaLink 327W?

    Hi, I was wondering what the correct URL is for the modem to check for updated firmware on the Westell VersaLink 327w. My model is the  D90-327W15-06 and its current firmware is 04.04.03
    To clarify, I'm looking for the URL that goes in the box at the top of the upgrade page in the router's advanced settings. That link is a screenshot of what my page currently looks like.
    Since I first got this modem 2 or 3 years ago, it has never been able to properly check for updates. I've tried changing the URL to point to the Verizon support page for manually downloading the firmware but that doesn't seem to work either. I'm guessing the URL should point to a specific file, possibly an xml or something? I don't remember what the original address in the box was but it didn't work anyway. 
    I'm pretty sure I am running the latest version (04.04.03) and manually upgrading isn't a problem if a new version comes out but its always bugged me that the built-in check has never worked right for me so I figured I'd ask on here for the heck of it. At the very least I'd like it to be able to check version information even if it can't upgrade automatically.
    Does the built-in firmware check work for anyone else using the 327w or similar model? If so, could you kindly copy/paste the URL on your modem's firmware page? Even if you have a different modem, it might help me figure out the right address for my own. Thanks!

    #1 Go to http://www.verizon.net/central/vzc.portal?_nfpb=true&_pageLabel=vzc_help_contentDisplay&linkflag=use...
    #2 Make sure that use save as.
    #3 After you save the file, go into your router's upgrade screen.
    #4 Then use the file that you downloaded earlier to upgrade the router..
    If you have any questions as how to do this..
    #1 Be sure to take screen shots.
    #2 And be sure that you use tinypic.com as your image host.
    If you are the original poster (OP) and your issue is solved, please remember to click the "Solution?" button so that others can more easily find it. If anyone has been helpful to you, please show your appreciation by clicking the "Kudos" button.

  • TS1424 i cannot play my videos or shows on itunes any more. i get the message saying "windows can check online for a solution to the problem" " i tunes has stopped working"

    i cannot play my videos or shows on itunes any more. i get the message saying "windows can check online for a solution to the problem" " i tunes has stopped working"

    Hi marymike,
    The crash signature is simalr to that mentioned in the thread: https://forums.adobe.com/thread/644139
    Please try the suggested steps mentioned and check.
    Regards,
    Rave

  • Open Item Management Check box for GL Account

    Hi,
    I need to activate Open Item Management check box for one GL Account. But it is not accepting since few postings were there in that GL Account.
    Kindly help me how to activate Open Item Management Check box for GL Account.
    Thanks
    KB
    Moderator: Please, search SDN before posting; this question has been answered dozens of times

    Hi,
    Check the below link. It might be useful for you.
    Open item management status change
    regards,
    Radhika.

  • F110 - Many Check no for multiple pages

    Dear Sapients,
    I have some issue with Automatic Payment Program using F110. We are using Non-Preprinted stationary with un-numbered checks, but system is assigning check no for each pages, if there are multiple pages for same vendor. Here is scanerio in more details:-
    1. Configuartion for F110 is done. Payment Method "C" is our payment method configured. All configuration is done and looks good.
    2. We have assigned FORM - /SMB11/CHECK_UNN, which is SAP standard form.
    3. We are using RFFOUS_C program for printing, which SAP allowed to use this print program for both pre-printing and non-pre-printed stationary for Check.
    4. When we execute program for vendor payment and vendor have say 50-60 invoices, system generate proposal correct, and post the document in payment run, but when we execute print for check printing, we check the spool request, it assign check number on each page. say it have 4 pages.
    (a) On page 1, check no would be say 2001 and it will VOID the check
    (b)  On page 2, check no would be say 2002 and it will VOID the check
    (c)  On page 3, check no would be say 2003 and it will print the check correctly.
    (d)  On page 4, check no would be say 2004 and it will VOID the check, This is summary page. ON summary page, it also give the check no details that from 2001 to 2004 check are assigned for this payment and check registered is updated properly.
    It should only assign one check no 2001 and shoudl only print the check on last page.
    Please advice.
    Thanks,
    Pawan Sharma

    Finally found the issue. In fact, we need to select "Do Not VOID any Check" in variant of program RFFOUS_C.
    For More Details, please read help for this check mark. It resovled my problem.
    If anyone have same issue, please use same process.
    Thanks,
    Pawan

Maybe you are looking for

  • How to import a track from DTR to DC perspective in Netweaver 7(Sp 18)

    Hi all,      the DC's that i had created are reflected in DTR but the same DC's are not gettin reflected in DC perspective. Is there any way by which i can directly get those DC's back into DC perspective and push them into the track again by creatin

  • TypeError: Error #1116: second argument to Function.prototype.apply must be an array

    Hi Frnds              I m loading an external swf into my swf using flex event.           e.target.content.addEventListener(FlexEvent.APPLICATION_COMPLETE,centerSWFLoad); but after this line it throws runtime 1116 error.please guide why this error oc

  • ADOBE AIR Corrupt

    Clicked on Help for the first time today. Dialog box came up stating an update is available. I installed it and got an error. I cannot use help. I get this: How do I reinstall Adobe Air without affecting anything else? Thanks, Peter

  • Testing GUI java based tool

    Hi friends, I am involved in a research project where we developed a GUI tool. At present i am testing this tool but i have some problems while testing. I am using Rational Robot software to test this tool but Robot cannot recognize some components l

  • Moving TV show from work computer to laptop

    I downloaded 2 episodes of Star Trek with my work computer T1 line. I want to put it on my laptop. I tried copying directly and Itune Backup. It got copied, but wanted me to reauthorize my computer. I did, but shows still won't play, though they show