|
From: <bc...@wo...> - 2001-02-10 11:13:37
|
[Brian Zhou]
>I'm using tomcat-3.2.1 on winNT/2k and linux.
>
>Testing dispatch.SimpleIncludeServlet under
>tomcat_home/webapps/WEB-INF/classes/
>
> http://localhost:8080/test/servlet/dispatch.SimpleIncludeServlet
>
>works perfectly fine, which returns
>
>LINE1
>TARGET1
>LINE2
>TARGET1
>LINE3
>
>in a text file.
>
>But when I translated it into jython servlet using:
>
># SimpleInclude.py
>import javax
>
>class SimpleInclude(javax.servlet.http.HttpServlet):
>
> def doGet(self, request, response):
> response.setContentType("text/plain")
> writer = response.getWriter()
> writer.println("LINE1")
> self.context = self.getServletConfig().getServletContext()
> s = "/Target1.py"
> rd = self.context.getRequestDispatcher(s)
> rd.include(request, response)
> writer.println("LINE2")
> rd.include(request, response)
> writer.println("LINE3")
>
># Target1.py
>import javax
>class Target1(javax.servlet.http.HttpServlet):
> def doGet(self, request, response):
> response.setContentType("text/plain")
> writer = response.getWriter()
> writer.println("TARGET1")
>
>All I got is a browser full of LINE1, and then tomcat died.
Thanks for the fine example. It fails for me too (tomcat-4.0m5).
>As a matter of fact, if I just want to rd.include a static page, it
>works fine.
>
>I think it must somehow get into a recursive and got stack overflown.
Correct.
Since the included resource is a .py file, the request is send to
PyServlet. Surprisingly (to me atleast) the request.getServletPath() is
still set to "/SimpleInclude.py". Instead I found the target path as
request.getAttribute("javax.servlet.include.servlet_path").
Does anyone know how the servlet docs describe this? Should PyServlet
check for the "..servlet_path" attribute and use that instead of the
request.getServletPath() when available?
It seems to work, but my knownledge about servlets is too small to be
sure. I have checked in this change so we can experiment with it.
regards,
finn
|