Infinite loop only on local server when forwarding to jsp

304 views
Skip to first unread message

Usul

unread,
Sep 2, 2013, 1:01:57 PM9/2/13
to google-a...@googlegroups.com
Hi,

in my servlet I do this:

        RequestDispatcher rd = mServletContext.getRequestDispatcher("/views/" + pViewName + ".jsp");
        rd
.forward(mRequest, mResponse);

All requests are handled by a servlet, which then forwards to the appropiate JSP.

I have a google app engine project with a maven structure (generated from the skeleton-archetype). So my structure looks like this.
  •  src
    • main
      • java
        • ... (code)
      • webapp
        • views
          • LoginView.jsp
          • MainView.jsp
          • ... (more jsp)
        • WEB-INF
    • test

My web.xml:
<?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/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
   
<servlet>
       
<servlet-name>HtmlStarterServlet</servlet-name>
       
<servlet-class>com.kupkik.ui.html.HtmlStarterServlet</servlet-class>
   
</servlet>
   
<servlet-mapping>
       
<servlet-name>HtmlStarterServlet</servlet-name>
       
<url-pattern>/*</url-pattern>
   
</servlet-mapping>
</web-app>

It all deploys and runs well on the google app engine.

But the local server creates infinite loops. I use the local server from the google app engine sdk dev_appserver.cmd. It seems, that the forwarding gets handled by HtmlStarterServletagain and thus an infinite loop is created. It should show the JSP, like it does online.

Can someone explain the different behaviour of the online google app engine and the local server of the SDK ? And does someone know a solution so that it works with both?

Thanks a lot!
Usul

P.S.
Output in browser:

HTTP ERROR 500

Problem accessing /. Reason:

    INTERNAL_SERVER_ERROR

Caused by:

java.lang.StackOverflowError

Vinny P

unread,
Sep 4, 2013, 1:04:51 AM9/4/13
to google-a...@googlegroups.com
On Mon, Sep 2, 2013 at 12:01 PM, Usul <skob...@gmail.com> wrote:
Can someone explain the different behaviour of the online google app engine and the local server of the SDK ? 


The development server doesn't perfectly emulate the production app engine environment. It does a terrific job, but there are some minor differences you'll hit now and again. This might be one of those occasions. 

 
On Mon, Sep 2, 2013 at 12:01 PM, Usul <skob...@gmail.com> wrote:
does someone know a solution so that it works with both?


I would try using a Filter ( http://www.oracle.com/technetwork/java/filters-137243.html ) which are much better for your use case; filters are intended for pre/post-processing requests before they're handled by servlets, which is exactly what you're trying to do. See here on how to map filters: https://developers.google.com/appengine/docs/java/config/webxml#Filters 
 

-----------------
-Vinny P
Technology & Media Advisor
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com

Reply all
Reply to author
Forward
0 new messages