Cookie name "Path" is a reserved token

987 views
Skip to first unread message

Lars Vonk

unread,
Jul 27, 2011, 6:07:32 AM7/27/11
to scalatra-user
Hi,

I have the following testcase:

test("POST / without username adds error message in flash") {
session {
post("/", "username" -> "", "password" -> "foo") {
status should equal(302)
}
get("/") {
body should include ("Username is mandatory");
}
}
}

When I run this test it fails, it doesn't include my flash message.
What I see in the log from eclispe is the following:

11:59:51.994 [qtp453897055-16 - /] DEBUG org.eclipse.jetty.util.log -
EXCEPTION
java.lang.IllegalArgumentException: Cookie name "Path" is a reserved
token
at javax.servlet.http.Cookie.<init>(Cookie.java:150) ~[servlet-
api-2.5.jar:2.5]
at
org.eclipse.jetty.server.CookieCutter.parseFields(CookieCutter.java:
304) [jetty-server-7.4.1.v20110513.jar:7.4.1.v20110513]
at org.eclipse.jetty.server.CookieCutter.getCookies(CookieCutter.java:
54) [jetty-server-7.4.1.v20110513.jar:7.4.1.v20110513]

Is the failure of creating the cookie the reason that I don't see the
flash message in the body?

The code for the get("/"):


def withLayout(body: NodeSeq): NodeSeq = {
val message = flash.get("message").map(text => <div>{ text }</
div>).getOrElse(Text(""))
<html>
<body>
{ message }
{ body }
</body>
</html>
}

get("/") {
withLayout {
<p>Ripe SSO</p>
<form method="POST">
Username:<input type="text" name="username"/><br/>
Password:<input type="password" value="password"/><br/>
<input type="submit" value="Login"/>
</form>
}
}
Thanks in advance,

Lars

Lars Vonk

unread,
Jul 27, 2011, 8:12:30 AM7/27/11
to scalatra-user
Replying to myself:

Found part of the issue. I didn't realize that doing a flash.get will
actually mark the message as to be removed.

The cookie warning still is there though but it doesn't seem influence
this. Perhaps that is just a Jetty issue.

Lars

Ross A. Baker

unread,
Jul 27, 2011, 4:23:13 PM7/27/11
to scalat...@googlegroups.com
Yes, flash.get marks the message for removal at the end of the request
in which you get it. This is a good fit for the standard
post-and-redirect pattern. Are you calling withLayout, or otherwise
calling flash.get, in your post action? I'm interested in any use
cases like that to ensure our behavior is a good one.

I just opened an issue on the cookie warnings:
https://github.com/scalatra/scalatra/issues/76. I think it's
harmless, but it's ugly and it's easily fixable.

--
Ross A. Baker
ba...@alumni.indiana.edu
Indianapolis, IN, USA

Lars Vonk

unread,
Jul 28, 2011, 2:11:47 AM7/28/11
to scalat...@googlegroups.com
Yes, when it didn't work because I am new to scalatra I put in some println's (I know :-)) for flash.get to see what was going.

So I actually caused the issue myself.

Thanks for replying.

Reply all
Reply to author
Forward
0 new messages