cookie example

Hi,

I was running below cookie example. I do not see my cookie name printed. How to fix it

 
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
public class CookieEx extends HttpServlet{
 
  public void doGet(HttpServletRequest request, HttpServletResponse response)
  throws IOException{
 
    response.setContentType("text/html");
    PrintWriter pw = response.getWriter();
 
    Cookie cookie = new Cookie("site","worlddddd.com");
    cookie.setMaxAge(60*60); //1 hour
    response.addCookie(cookie);
 
    pw.println("Cookies was generated");
    System.out.println("cookie.getName()"+cookie.getName());
    //pw.println("cookie.getName()"+cookie.getName());
  }
} 

Open in new window



Do I supposed to use sytem out or print writer as below

   System.out.println("cookie.getName()"+cookie.getName());
   

pw.println("cookie.getName()"+cookie.getName());

How do i view all recent cookies in IE and mozilla and chrome.
Please advise.

Any links resources ideas highly appreciated. Thanks in advance
LVL 7
gudii9Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
In Firefox, go to Tools -> Options -> Privacy.  Select Custom setting in the middle of the dialog window and a button to show your cookies will appear.
Firefox Options
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gudii9Author Commented:
How to check in IE and chrome as well?l  use them more. Please advise
0
Dave BaldwinFixer of ProblemsCommented:
I don't know of any way to check cookies in IE although there is a directory that is used to store them.  In Chrome, go to 'Setting' -> 'Content Settings' under Privacy and click on 'All Cookies and Site Data'.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.