You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sharon Cohen <sh...@hotmail.com> on 2003/08/05 14:42:59 UTC
Front Controller Servlet
I am trying to build FrontController servlet for a web site on Tomcat 4 ,
after long time of changes on the web.xml file , I wasn't able to achieve
this pattern,
the web.xml portion is :
<servlet-mapping>
<servlet-name>FCservlet</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
my problem start when the FrontController servlet needs to forward the
request to other jsp pages
and when he uses the Forward method , the tomcat activate my FrontController
again , and after a while I get : StackOverflowError .
Thanks for any help
Sharon
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Front Controller Servlet
Posted by Bill Barker <wb...@wilshire.com>.
I agree that the design isn't the greatest (but I've seen much worse ;-). To
do what you want, in FCServlet try something like:
if(request.getServletPath().endsWith(".jsp")) {
RequestDispatcher rd = getServletContext().getNamedDispatcher("jsp");
rd.forward(request, response);
return;
}
"Sharon Cohen" <sh...@hotmail.com> wrote in message
news:BAY2-DAV25O5w6WGvyG0001d00d@hotmail.com...
> I am trying to build FrontController servlet for a web site on Tomcat 4 ,
> after long time of changes on the web.xml file , I wasn't able to achieve
> this pattern,
> the web.xml portion is :
>
> <servlet-mapping>
> <servlet-name>FCservlet</servlet-name>
> <url-pattern>*.jsp</url-pattern>
> </servlet-mapping>
>
> my problem start when the FrontController servlet needs to forward the
> request to other jsp pages
> and when he uses the Forward method , the tomcat activate my
FrontController
> again , and after a while I get : StackOverflowError .
>
> Thanks for any help
> Sharon
Re: Front Controller Servlet
Posted by Bill Barker <wb...@wilshire.com>.
I agree that the design isn't the greatest (but I've seen much worse ;-). To
do what you want, in FCServlet try something like:
if(request.getServletPath().endsWith(".jsp")) {
RequestDispatcher rd = getServletContext().getNamedDispatcher("jsp");
rd.forward(request, response);
return;
}
"Sharon Cohen" <sh...@hotmail.com> wrote in message
news:BAY2-DAV25O5w6WGvyG0001d00d@hotmail.com...
> I am trying to build FrontController servlet for a web site on Tomcat 4 ,
> after long time of changes on the web.xml file , I wasn't able to achieve
> this pattern,
> the web.xml portion is :
>
> <servlet-mapping>
> <servlet-name>FCservlet</servlet-name>
> <url-pattern>*.jsp</url-pattern>
> </servlet-mapping>
>
> my problem start when the FrontController servlet needs to forward the
> request to other jsp pages
> and when he uses the Forward method , the tomcat activate my
FrontController
> again , and after a while I get : StackOverflowError .
>
> Thanks for any help
> Sharon
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Front Controller Servlet
Posted by Justin Ruthenbeck <ju...@nextengine.com>.
At 05:42 AM 8/5/2003, you wrote:
>I am trying to build FrontController servlet for a web site on Tomcat 4 ,
>after long time of changes on the web.xml file , I wasn't able to achieve
>this pattern,
>the web.xml portion is :
>
><servlet-mapping>
> <servlet-name>FCservlet</servlet-name>
> <url-pattern>*.jsp</url-pattern>
></servlet-mapping>
>
>my problem start when the FrontController servlet needs to forward the
>request to other jsp pages
>and when he uses the Forward method , the tomcat activate my FrontController
>again , and after a while I get : StackOverflowError .
You say that you're using the forward() method -- why? There are reasons
to do this, but if you're trying to create a FrontController, then
presumably you're not interested in hitting your jsps directly in the first
place. Is there any reason you aren't using a RequestDispatcher to
dispatch/include your jsp page output instead of forwarding to the page?
justin
____________________________________
Justin Ruthenbeck
Software Engineer, NextEngine Inc.
justinr - AT - nextengine DOT com
Confidential
See http://www.nextengine.com/confidentiality.php
____________________________________
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Front Controller Servlet
Posted by Mike Curwen <gb...@gb-im.com>.
That's because you're trying to implement as front controller
**servlet** as a JSP ?
Map your controller servlet to /foo (or anything *other* than *.jsp)
then requests could all go to the controller servlet, and your servlet
could send it off to any *.jsp page without invoking itself infinitely.
> -----Original Message-----
> From: Sharon Cohen [mailto:sharon669@hotmail.com]
> Sent: Tuesday, August 05, 2003 7:43 AM
> To: tomcat-user@jakarta.apache.org
> Subject: Front Controller Servlet
>
>
> I am trying to build FrontController servlet for a web site
> on Tomcat 4 , after long time of changes on the web.xml file
> , I wasn't able to achieve this pattern, the web.xml portion is :
>
> <servlet-mapping>
> <servlet-name>FCservlet</servlet-name>
> <url-pattern>*.jsp</url-pattern>
> </servlet-mapping>
>
> my problem start when the FrontController servlet needs to
> forward the request to other jsp pages and when he uses the
> Forward method , the tomcat activate my FrontController again
> , and after a while I get : StackOverflowError .
>
> Thanks for any help
> Sharon
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Front Controller Servlet
Posted by Mike Curwen <gb...@gb-im.com>.
That's because you're trying to implement as front controller
**servlet** as a JSP ?
Map your controller servlet to /foo (or anything *other* than *.jsp)
then requests could all go to the controller servlet, and your servlet
could send it off to any *.jsp page without invoking itself infinitely.
> -----Original Message-----
> From: Sharon Cohen [mailto:sharon669@hotmail.com]
> Sent: Tuesday, August 05, 2003 7:43 AM
> To: tomcat-user@jakarta.apache.org
> Subject: Front Controller Servlet
>
>
> I am trying to build FrontController servlet for a web site
> on Tomcat 4 , after long time of changes on the web.xml file
> , I wasn't able to achieve this pattern, the web.xml portion is :
>
> <servlet-mapping>
> <servlet-name>FCservlet</servlet-name>
> <url-pattern>*.jsp</url-pattern>
> </servlet-mapping>
>
> my problem start when the FrontController servlet needs to
> forward the request to other jsp pages and when he uses the
> Forward method , the tomcat activate my FrontController again
> , and after a while I get : StackOverflowError .
>
> Thanks for any help
> Sharon
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
Re: Front Controller Servlet
Posted by Dionisio Ruiz de Zarate <di...@tinieblas.com>.
and whoy don't use one filter?
i am usin one filter; in my web.xml i have mapped all my jsp pages (*.jsp)
to this filter, an the filter actions are made first and in the second fase
the systems shows me the jsp page
----- Original Message -----
From: <pe...@kisstechnologies.co.uk>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Wednesday, August 06, 2003 12:59 AM
Subject: Re: Front Controller Servlet
> The reason it is crashing is because you are forwarding to a JSP page,
> however you have already taken over jsp processing in your servlet by
> declaring that it should handle *.jsp, thus it forwards in a circle until
> it runs out of stack space.
> Try using another extension for your controller, such as .ktx as we use in
> ours. This can then forward sucessfully to jsps!
>
> Should be:
> <servlet-mapping>
> <servlet-name>FCservlet</servlet-name>
> <url-pattern>*.ktx</url-pattern>
> </servlet-mapping>
>
> Then your links can be to index.ktx instead and it will got through ok.
> Pete
>
> Kiss Technologies
>
> http://www.kisstechnologies.co.uk/
>
> 4, Percy Street
> London
> W1T 1DF
>
> Phone numbers:
>
> Phone 020 7692 9922
> Fax 020 7692 9923
>
>
>
>
> "Sharon Cohen" <sh...@hotmail.com>
> 05/08/2003 13:42
> Please respond to "Tomcat Users List"
>
> To: <to...@jakarta.apache.org>
> cc:
> Subject: Front Controller Servlet
>
>
> I am trying to build FrontController servlet for a web site on Tomcat 4 ,
> after long time of changes on the web.xml file , I wasn't able to achieve
> this pattern,
> the web.xml portion is :
>
> <servlet-mapping>
> <servlet-name>FCservlet</servlet-name>
> <url-pattern>*.jsp</url-pattern>
> </servlet-mapping>
>
> my problem start when the FrontController servlet needs to forward the
> request to other jsp pages
> and when he uses the Forward method , the tomcat activate my
> FrontController
> again , and after a while I get : StackOverflowError .
>
> Thanks for any help
> Sharon
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
Re: Front Controller Servlet
Posted by Dionisio Ruiz de Zarate <di...@tinieblas.com>.
and whoy don't use one filter?
i am usin one filter; in my web.xml i have mapped all my jsp pages (*.jsp)
to this filter, an the filter actions are made first and in the second fase
the systems shows me the jsp page
----- Original Message -----
From: <pe...@kisstechnologies.co.uk>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Wednesday, August 06, 2003 12:59 AM
Subject: Re: Front Controller Servlet
> The reason it is crashing is because you are forwarding to a JSP page,
> however you have already taken over jsp processing in your servlet by
> declaring that it should handle *.jsp, thus it forwards in a circle until
> it runs out of stack space.
> Try using another extension for your controller, such as .ktx as we use in
> ours. This can then forward sucessfully to jsps!
>
> Should be:
> <servlet-mapping>
> <servlet-name>FCservlet</servlet-name>
> <url-pattern>*.ktx</url-pattern>
> </servlet-mapping>
>
> Then your links can be to index.ktx instead and it will got through ok.
> Pete
>
> Kiss Technologies
>
> http://www.kisstechnologies.co.uk/
>
> 4, Percy Street
> London
> W1T 1DF
>
> Phone numbers:
>
> Phone 020 7692 9922
> Fax 020 7692 9923
>
>
>
>
> "Sharon Cohen" <sh...@hotmail.com>
> 05/08/2003 13:42
> Please respond to "Tomcat Users List"
>
> To: <to...@jakarta.apache.org>
> cc:
> Subject: Front Controller Servlet
>
>
> I am trying to build FrontController servlet for a web site on Tomcat 4 ,
> after long time of changes on the web.xml file , I wasn't able to achieve
> this pattern,
> the web.xml portion is :
>
> <servlet-mapping>
> <servlet-name>FCservlet</servlet-name>
> <url-pattern>*.jsp</url-pattern>
> </servlet-mapping>
>
> my problem start when the FrontController servlet needs to forward the
> request to other jsp pages
> and when he uses the Forward method , the tomcat activate my
> FrontController
> again , and after a while I get : StackOverflowError .
>
> Thanks for any help
> Sharon
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Front Controller Servlet
Posted by pe...@kisstechnologies.co.uk.
The reason it is crashing is because you are forwarding to a JSP page,
however you have already taken over jsp processing in your servlet by
declaring that it should handle *.jsp, thus it forwards in a circle until
it runs out of stack space.
Try using another extension for your controller, such as .ktx as we use in
ours. This can then forward sucessfully to jsps!
Should be:
<servlet-mapping>
<servlet-name>FCservlet</servlet-name>
<url-pattern>*.ktx</url-pattern>
</servlet-mapping>
Then your links can be to index.ktx instead and it will got through ok.
Pete
Kiss Technologies
http://www.kisstechnologies.co.uk/
4, Percy Street
London
W1T 1DF
Phone numbers:
Phone 020 7692 9922
Fax 020 7692 9923
"Sharon Cohen" <sh...@hotmail.com>
05/08/2003 13:42
Please respond to "Tomcat Users List"
To: <to...@jakarta.apache.org>
cc:
Subject: Front Controller Servlet
I am trying to build FrontController servlet for a web site on Tomcat 4 ,
after long time of changes on the web.xml file , I wasn't able to achieve
this pattern,
the web.xml portion is :
<servlet-mapping>
<servlet-name>FCservlet</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
my problem start when the FrontController servlet needs to forward the
request to other jsp pages
and when he uses the Forward method , the tomcat activate my
FrontController
again , and after a while I get : StackOverflowError .
Thanks for any help
Sharon
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: Front Controller Servlet
Posted by Justin Ruthenbeck <ju...@nextengine.com>.
At 05:42 AM 8/5/2003, you wrote:
>I am trying to build FrontController servlet for a web site on Tomcat 4 ,
>after long time of changes on the web.xml file , I wasn't able to achieve
>this pattern,
>the web.xml portion is :
>
><servlet-mapping>
> <servlet-name>FCservlet</servlet-name>
> <url-pattern>*.jsp</url-pattern>
></servlet-mapping>
>
>my problem start when the FrontController servlet needs to forward the
>request to other jsp pages
>and when he uses the Forward method , the tomcat activate my FrontController
>again , and after a while I get : StackOverflowError .
You say that you're using the forward() method -- why? There are reasons
to do this, but if you're trying to create a FrontController, then
presumably you're not interested in hitting your jsps directly in the first
place. Is there any reason you aren't using a RequestDispatcher to
dispatch/include your jsp page output instead of forwarding to the page?
justin
____________________________________
Justin Ruthenbeck
Software Engineer, NextEngine Inc.
justinr - AT - nextengine DOT com
Confidential
See http://www.nextengine.com/confidentiality.php
____________________________________