473,396 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

JSP & JavaScript: don't grok cookies?

I have a JSP which does request.addCookie(cookie), then <c:redirect/>
to a second JSP. Said second JSP reads the given cookies via JSP and
sees that all is well: the cookies have arrived. Said second JSP
*also* has some JavaScript code reading the same cookies, but they are
not found.

How come that JavaScript can't read the cookies set via JSP?

I create the cookies in the first JSP like this:

Cookie cook = new Cookie("foo", "bar");
cook.setPath("/evITA-Web");
response.addCookie(cook);

And the JavaScript code to read them looks like this:

function get_cookie(name) {
var regexp = new RegExp(name + "=([^;]+)");
var cookie_match = document.cookie.match(regexp);
if (cookie_match) {
return cookie_match[1];
} else {
return null;
}
}

I'm trying this out in IE 6 on W2k/pro. The server side is a Tomcat
5.0.16.

Kai

Jul 20 '05 #1
7 3051
nos
you need the javaAintJavascript()

"Kai Grossjohann" <ka*@emptydomain.de> wrote in message
news:87************@emptyhost.emptydomain.de...
I have a JSP which does request.addCookie(cookie), then <c:redirect/>
to a second JSP. Said second JSP reads the given cookies via JSP and
sees that all is well: the cookies have arrived. Said second JSP
*also* has some JavaScript code reading the same cookies, but they are
not found.

How come that JavaScript can't read the cookies set via JSP?

I create the cookies in the first JSP like this:

Cookie cook = new Cookie("foo", "bar");
cook.setPath("/evITA-Web");
response.addCookie(cook);

And the JavaScript code to read them looks like this:

function get_cookie(name) {
var regexp = new RegExp(name + "=([^;]+)");
var cookie_match = document.cookie.match(regexp);
if (cookie_match) {
return cookie_match[1];
} else {
return null;
}
}

I'm trying this out in IE 6 on W2k/pro. The server side is a Tomcat
5.0.16.

Kai

Jul 20 '05 #2
> "Kai Grossjohann" <ka*@emptydomain.de> wrote in message
news:87************@emptyhost.emptydomain.de...
I have a JSP which does request.addCookie(cookie), then <c:redirect/>

"nos" <no*@nospam.com> wrote in message
news:940Eb.581886$Fm2.540014@attbi_s04... you need the javaAintJavascript()


The 'J' in JSP does not stand for JavaScript, nos.

(and please do not top post)

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
Jul 20 '05 #3
nos
oops, sorry
what is top post?

"Andrew Thompson" <an******@bigNOSPAMpond.com> wrote in message
news:Bh******************@news-server.bigpond.net.au...
"Kai Grossjohann" <ka*@emptydomain.de> wrote in message
news:87************@emptyhost.emptydomain.de...
I have a JSP which does request.addCookie(cookie), then <c:redirect/>


"nos" <no*@nospam.com> wrote in message
news:940Eb.581886$Fm2.540014@attbi_s04...
you need the javaAintJavascript()


The 'J' in JSP does not stand for JavaScript, nos.

(and please do not top post)

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site

Jul 20 '05 #4
"nos" <no*@nospam.com> wrote in news:Dk0Eb.575895$Tr4.1550762@attbi_s03:
oops, sorry
what is top post?


http://www.html-faq.com/etiquette/?toppost
Jul 20 '05 #5
"nos" <no*@nospam.com> writes:
you need the javaAintJavascript()


Huh? I know that Java ain't JavaScript.

Kai
Jul 20 '05 #6
"nos" <no*@nospam.com> wrote in message
news:Dk0Eb.575895$Tr4.1550762@attbi_s03...
oops, sorry
what is top post?


...hmmm. Are you extracting the urine?

In any case, for those that are not aware..
http://www.allmyfaqs.com/faq.pl?How_to_post

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
Jul 20 '05 #7
"Thomas Schodt" <news0310@xenoc.$DEMON.co.uk> wrote in message
news:Xn*******************@158.152.254.254...
"nos" <no*@nospam.com> wrote in news:Dk0Eb.575895$Tr4.1550762@attbi_s03:
oops, sorry
what is top post?


http://www.html-faq.com/etiquette/?toppost


Thanks Thomas, when I googled it I was
swamped with hits. That was the one I
was looking for.
Jul 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gowhera Hussain | last post by:
Use This for Learning Only .... Do Not Try To Act Smart HACKING WITH JAVASCRIPT Dr_aMado Sun, 11 Apr 2004 16:40:13 UTC This tutorial is an overview of how javascript can be used to bypass...
2
by: Don Grover | last post by:
I have to modify a site that uses both Cookies & & Session variables, (Array) So that it reports back in a web page if they have cookies or Session variables security high or locked out. Im...
2
by: Michael | last post by:
I am reading and setting a cookie using JavaScript in the BODY onload and onunload events respectively. This works fine. However when I use ASP to set the cookie under some condition where I...
4
by: changed | last post by:
I have an application that works almost all of the time but there is an inconsistent error with some browsers (some Mac, some PC). It seems that the cookie won't get written before the redirect. ...
1
by: John Taylor-Johnston | last post by:
I'm a University academic looking for a proper definition of JavaScript Cookies. http://www.CollegeSherbrooke.qc.ca/languesmodernes/604-HAE_Grammar_Practice/ I'm trying to decipher what...
1
by: Srinivasa Raghavan | last post by:
Hi All, I am having a userobject(class) which is put into a session.The Session variable is expiring after 10 to 15 minutes.I don't why can any one explain what could be the reason. I am...
9
by: SHarris | last post by:
Hello, In our new intranet ASP.NET project, two requirements are that the browser accept cookies AND JavaScript. We are requiring the use of Internet Explorer 6+. 1. Using C# in an ASP.NET...
2
by: Esa | last post by:
Hi, I'm having problems with one strange web system where submitting an application and making queries about its handling status require a series of form submits and response parsing - all in...
7
by: bhavin30 | last post by:
Is there a way to obtain user information (using LOGON_USER server variables) when you have set up the security to Anonymous Access? I have tried setting the security to both Anonymous + Window...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.