I created a simple servlet filter like so...

public void doFilter(
  ServletRequest request,
  ServletResponse response,
  FilterChain chain)
  throws IOException, ServletException
{

((HttpServletRequest)request).getRequestDispatcher("/action/home").forward(r
equest, response);
}

and add this into web.xml ...

<filter>
  <filter-name>forward</filter-name>
  <filter-class>com.buildabreak.util.ForwardFilter</filter-class>
</filter>

<filter-mapping>
  <filter-name>forward</filter-name>
  <url-pattern>/</url-pattern>
</filter-mapping>

Should be easy to make it more flexible by using the FilterConfig to read
the URL to redirect to rather than hard coding it in there.

John

----- Original Message ----- 
From: "Sergiy Barlabanov" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, December 03, 2003 9:57 AM
Subject: RE: [OS-webwork] Tomcat forward


John,
could you explain your approach in several words? We have to do forwards
within our portal too.

regards,
Sergey

-----Original Message-----
From: John Patterson [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 02, 2003 10:52 PM
To: [EMAIL PROTECTED]
Subject: Re: [OS-webwork] Tomcat forward


Thanks for the suggestions but I think that the Filter approach is simpler
and more search engine friendly.

The question was actually asking for a method of doing an internal
'forward' (dispatcher.forward()), rather than a 'redirect'
(response.sendRedirect() or html refresh).  This means one less server trip
rather than one more.

It also means that whenever the url appears on other web pages it
contributes to your home page's search engine page rank.

I have implemented this as a Filter which works well and is portable.

John.

----- Original Message ----- 
From: "Hani Suleiman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 02, 2003 4:58 PM
Subject: Re: [OS-webwork] Tomcat forward


> You could use sitemesh to decorate a remote url, but really, what you
> want to do is fairly silly, since you're incurring an extra network trip
> (from the server to your homepage) for no reason other than to have a
> slightly prettier url.
>
> John Patterson wrote:
>
> > Hi,  I know this is off topic but I was wondering how others handle this
> > issue.
> >
> > I want my domain www.domain.co.uk <http://www.domain.co.uk> to forward
> > directly to my home page. That is, I do not want it to *redirect* making
> > the browser's URL change.
> >
> > Is making a Filter the only cross platform way to do?
> >
> > Thanks,
> >
> > John.
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program.
> Does SourceForge.net help you be more productive?  Does it
> help you create better code?  SHARE THE LOVE, and help us help
> YOU!  Click Here: http://sourceforge.net/donate/
> _______________________________________________
> Opensymphony-webwork mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
>


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to