Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


How can I handle cookies?

Posted on 2003-11-20
Medium Priority
Last Modified: 2010-04-01
Hi all,

I want to save the member login information in Cookies. After user login, the information will be auto-add to client side PC, and show it in FORM next time. Once I put the GETCOOKIES statement, it generated error when enter the site said that: java.lang.NullPointerException.

But, when the user logined before, this error will not be show. I know that it is the error about the Cookie, but, how can I know the cookies has data or not before get it?

here is my code:

String cookiemail="";
Cookie cookies[]=request.getCookies();

for (int i=0;i<cookies.length;i++){

please help. Thanks!
Question by:efkw
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment

Accepted Solution

DidierD earned 260 total points
ID: 9795410
Try this

String cookiemail="";
Cookie cookies[]=request.getCookies();

if (cookies != null){
  for (int i=0;i<cookies.length;i++){

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question