Created
June 30, 2011 04:49
-
-
Save rossabaker/1055654 to your computer and use it in GitHub Desktop.
Scalatra Issue #57 -- works for me
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example | |
import org.scalatra._ | |
class FormServlet extends ScalatraServlet with FlashMapSupport { | |
get("/form") { | |
<form action="/form-servlet/form" method="post"> | |
<input type="submit" value="Submit" /> | |
</form> | |
} | |
post("/form") { | |
flash("foo") = "bar" | |
redirect("/other-servlet/show-flash") | |
} | |
} | |
class OtherServlet extends ScalatraServlet with FlashMapSupport { | |
get("/show-flash") { | |
"Foo = " + flash("foo") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns="http://java.sun.com/xml/ns/javaee" | |
xmlns:web="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" | |
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" | |
version="2.4"> | |
<servlet> | |
<servlet-name>scalatra</servlet-name> | |
<servlet-class> | |
com.example.FormServlet | |
</servlet-class> | |
</servlet> | |
<servlet-mapping> | |
<servlet-name>scalatra</servlet-name> | |
<url-pattern>/form-servlet/*</url-pattern> | |
</servlet-mapping> | |
<servlet> | |
<servlet-name>other</servlet-name> | |
<servlet-class> | |
com.example.OtherServlet | |
</servlet-class> | |
</servlet> | |
<servlet-mapping> | |
<servlet-name>other</servlet-name> | |
<url-pattern>/other-servlet/*</url-pattern> | |
</servlet-mapping> | |
</web-app> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I execute this, it shows the flash message but if I reload the show-flash action the message stays. I extended the example a little bit:
The following things happen:
Another interesting detail:
If I access /other-servlet/show-flash as the first request, I get an exception (of course).
But if I submit the form afterwards it doesn't work anymore. I always get a NoSuchElementException, even if I repeat submitting the form.
I'm using jetty 6.1.26. Do you think jetty could be the problem?