You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Tim Funk <fu...@joedog.org> on 2006/09/12 12:39:12 UTC
Re: How to redirect to a jsp
If I am reading this correctly, an "easier" solution would be to create
an index.jsp at the root level that forwards to "/jsp/index.jsp"
-Tim
Romain Quilici wrote:
> Hi all,
> this question seems simple, but I did not figure out how to answer it.
>
> In my web.xml I have defined a default servlet. So it can handle
> requests that does not match other servlets pattern.
> <servlet-mapping>
> <servlet-name>DefaultServlet</servlet-name>
> <url-pattern>/</url-pattern>
> </servlet-mapping>
>
> Then in my DefaultServlet, I want to redirect to a jsp page, so I use
> RequestDispatcher dispatcher =
> getServletContext().getRequestDispatcher("/jsp/index.jsp");
> if(dispatcher != null){
> dispatcher.forward(request,response);
> }
>
> But doing that, I reenter in my default servlet's doGet method.
>
> What I want is rather simple, when a user connect to the site
> http://server/myapp/, then the request is handled by the default
> servlet and the jsp page is displayed
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: How to redirect to a jsp
Posted by Marc Farrow <ma...@gmail.com>.
Tim's solution is the easiest, but allow me to explain why your application
is behaving that way.
By specifying the following
> <url-pattern>/</url-pattern>
>
>
You are saying that all requests that come into your application are to be
forwarded to the servlet. Thus when you redirect to "/jsp/index.jsp" it is
taking back into the servlet. My guess is that you are trying to force
everyone to the /jsp/index.jsp" page no matter which "url" they use to get
to your application. I do not know of an easy way to do this. I like Tim's
solution and hopefully that will fulfill your needs.
HTH
On 9/12/06, Tim Funk <fu...@joedog.org> wrote:
>
> If I am reading this correctly, an "easier" solution would be to create
> an index.jsp at the root level that forwards to "/jsp/index.jsp"
>
> -Tim
>
> Romain Quilici wrote:
> > Hi all,
> > this question seems simple, but I did not figure out how to answer it.
> >
> > In my web.xml I have defined a default servlet. So it can handle
> > requests that does not match other servlets pattern.
> > <servlet-mapping>
> > <servlet-name>DefaultServlet</servlet-name>
> > <url-pattern>/</url-pattern>
> > </servlet-mapping>
> >
> > Then in my DefaultServlet, I want to redirect to a jsp page, so I use
> > RequestDispatcher dispatcher =
> > getServletContext().getRequestDispatcher("/jsp/index.jsp");
> > if(dispatcher != null){
> > dispatcher.forward(request,response);
> > }
> >
> > But doing that, I reenter in my default servlet's doGet method.
> >
> > What I want is rather simple, when a user connect to the site
> > http://server/myapp/, then the request is handled by the default
> > servlet and the jsp page is displayed
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
--
Marc Farrow