Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JSP Cookie problem

843833Aug 16 2005 — edited Aug 24 2005
Starting to use cookies to tie a login across multiple apps. Have read some tutorials but with no luck im afraid. Im using the latest stable tomcat 5.

Ive started simple by simpy trying to read all the cookies and their names on my system to get a basis of what i need:
<%@ page import="java.net.*"%>
<% 
	Cookie cookies [] = request.getCookies ();
	Cookie redCookie = null;
	if (cookies != null)
	{
		for (int i = 0; i < cookies.length; i++) 
		{
			out.println(cookies.length + ":" + i + " - " + cookies .getName() + " = " + cookies .getValue());
		}
	}
%>
This code does not work and according to the numerous examples ive looked at it should.

The error tomcat throws is:

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 2 in the jsp file: /jsp/cook.jsp
Generated servlet error:
Cannot invoke getName() on the array type Cookie[]

An error occurred at line: 2 in the jsp file: /jsp/cook.jsp
Generated servlet error:
Cannot invoke getValue() on the array type Cookie[]

Any help on this matter would be greatly appreciated.

Thanks
Ben
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 21 2005
Added on Aug 16 2005
3 comments
307 views