473,671 Members | 2,255 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JSP & JavaScript: don't grok cookies?

I have a JSP which does request.addCook ie(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.addCoo kie(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 3063
nos
you need the javaAintJavascr ipt()

"Kai Grossjohann" <ka*@emptydomai n.de> wrote in message
news:87******** ****@emptyhost. emptydomain.de. ..
I have a JSP which does request.addCook ie(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.addCoo kie(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*@emptydomai n.de> wrote in message
news:87******** ****@emptyhost. emptydomain.de. ..
I have a JSP which does request.addCook ie(cookie), then <c:redirect/>

"nos" <no*@nospam.com > wrote in message
news:940Eb.5818 86$Fm2.540014@a ttbi_s04... you need the javaAintJavascr ipt()


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******@bigNO SPAMpond.com> wrote in message
news:Bh******** **********@news-server.bigpond. net.au...
"Kai Grossjohann" <ka*@emptydomai n.de> wrote in message
news:87******** ****@emptyhost. emptydomain.de. ..
I have a JSP which does request.addCook ie(cookie), then <c:redirect/>


"nos" <no*@nospam.com > wrote in message
news:940Eb.5818 86$Fm2.540014@a ttbi_s04...
you need the javaAintJavascr ipt()


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.5758 95$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 javaAintJavascr ipt()


Huh? I know that Java ain't JavaScript.

Kai
Jul 20 '05 #6
"nos" <no*@nospam.com > wrote in message
news:Dk0Eb.5758 95$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.5758 95$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
7064
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 simple/advanced html forms and how it can be used to override cookie/session
2
1522
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 having problem where IT staff are setting security so high that the site wont displau and just gives an error. As soon as I told the person to reset there browser to default it worked ok. Error was: 'A run time error has occurred. Do you wish to...
2
5567
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 want to override the last value set in the onunload event, it has no effect. The next onload still has the old value. Any ideas? The following code simulates the problem I experience. --------------------------------------------------
4
21683
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. If I turn on cookie prompting my computer will stall just after this cookie is written (if it's even written) *MOST* of the time. setCookie("FC2", escape(escape(getCookie("FC"))), "", "/", ".lacs.utexas.edu", false); window.location =...
1
3174
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 categor(ies) JavaScript cookies fall under, according to Internet Explorer's help.cfm. What I don't understand is where do JavaScript cookies fall under the help.cfm definition. Maybe I'm not reading "their" English properly? (See below.) "Persistent -...
1
1126
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 storing cookies in the client side using httpcookie object.It is working in IE and not in netscape.please suggest a solution.
9
3054
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 application, how can we code the project to check to make sure the browser accepts cookies? 2. Where would we put this code? In Global.asax? 3. Using C# in an ASP.NET application, how can we code the project to detect and make sure the browser...
2
2285
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 HTML. Luckily other interfaces are "modern" using xml file up/downloads without any difficulties... I'm not very used to .NET-environment yet, so I'd appreciate some clues about the classes I should use to implement this stupid interface - stupid...
7
5345
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 Integrated, without any luck. I'm using IIS 6.0 on Windows Server 2003 Thanks in advance!
0
8476
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8393
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8820
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8598
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8670
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6223
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2810
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.