AppEngine Development Server Provides StackOverflowError in JSP

I use the following code in a JSP file that I serve from AppEngine serlvet.

 <script type="text/javascript" > var role = <%= request.getAttribute("role") %>; </script> 

The variable is set from the Servlet using:

 req.setAttribute("role", role ); req.getRequestDispatcher("index.jsp").forward(req, resp); 

The code works fine when creating AppEngine, but on the local development server I immediately get the following:

 Problem accessing /. Reason: INTERNAL_SERVER_ERROR Caused by: java.lang.StackOverflowError at org.mortbay.jetty.servlet.Dispatcher$ForwardAttributes.setAttribute(Dispatcher.java:438) at org.mortbay.jetty.servlet.Dispatcher$ForwardAttributes.setAttribute(Dispatcher.java:438) at org.mortbay.jetty.servlet.Dispatcher$ForwardAttributes.setAttribute(Dispatcher.java:438) at org.mortbay.jetty.servlet.Dispatcher$ForwardAttributes.setAttribute(Dispatcher.java:438) at org.mortbay.jetty.servlet.Dispatcher$ForwardAttributes.setAttribute(Dispatcher.java:438) at org.mortbay.jetty.servlet.Dispatcher$ForwardAttributes.setAttribute(Dispatcher.java:438) at org.mortbay.jetty.servlet.Dispatcher$ForwardAttributes.setAttribute(Dispatcher.java:438) 

it continues as always. During debugging, I also see that the servlet code is called infinite.

I found several links to a similar problem with AppEngine products, but I did not find a working fix for the AppEngine development server.

Any idea?

+2
source share
2 answers

I had a similar problem when sending to the JSP from the servlet using the Google App Engine without explicitly setting any variables, all I had was a line:

 req.getRequestDispatcher("game.jsp").forward(req, resp); 

In my case, it turned out because in web.xml I had the following line (note the catch-all catch pattern:

 <servlet-mapping> <servlet-name>GameServlet</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> 

I think this also captured the JSP path and therefore the loop. When I change it, this is not a trick either, it works. How in:

 <servlet-mapping> <servlet-name>GameServlet</servlet-name> <url-pattern>/game</url-pattern> </servlet-mapping> 
+4
source

Are you sure you are setting the attribute in the response?

 req.setAttribute("role", role ); 

It looks like you are setting it in the request that hit the servlet, and not in the response you are sending.

0
source

All Articles