Linking/forwarding GET requests using Default servlet or other Tomcat feature

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Linking/forwarding GET requests using Default servlet or other Tomcat feature

Rob Hunt
I'm running a stand-alone (no Apache front-end) TC 5.0.19 server on a WinXP box.  I have a webapp that has a /teams directory that contains gameScores.htm, teamStandings.htm and scoreForm.htm.  I also have a /playoffs directory (can you tell this is a sports-related site?) directory that has the **exact same files**.  

Now, I'd like to keep a single copy of the 3 files in one directory and have some <servlet-mapping>s  in web.xml that would "forward" the request from /playoffs to /teams **WITHOUT** the HTTP client being aware of a 'redirect.'  That is, I don't want to issue an HTTP redirect, and WinXP doesn't have file linking like Unix.  Is there some hook in the Default servlet (or other TC-supplied class) that would allow one to do something like the following:

  <servlet>
    <servlet-name>playoffs</servlet-name>
    <servlet-class>...DefaultServlet (or whatever)</servlet-class>
    <init-param>
      <param-name>FORWARD</param-name>
      <param-value>/teams</param-value>
    </init-param>
  </servlet>
  <servlet-mapping>
    <servlet-name>playoffs</servlet-name>
    <url-pattern>/playoffs/*</url-pattern>
  </servlet-mapping>


The idea is I'm being very lazy and hoping that there is a feature in the default servlet (or other TC-supplied filter/class) that will allow this without me having to write same.  (Of, if someone has some code they'd like to share...)

Thanks.

Reply | Threaded
Open this post in threaded view
|

Re: Linking/forwarding GET requests using Default servlet or other Tomcat feature

Ben Souther
On Wed, 2005-07-27 at 12:19, Rob Hunt wrote:

> I'm running a stand-alone (no Apache front-end) TC 5.0.19 server on a WinXP box.  I have a webapp that has a /teams directory that contains gameScores.htm, teamStandings.htm and scoreForm.htm.  I also have a /playoffs directory (can you tell this is a sports-related site?) directory that has the **exact same files**.  
>
> Now, I'd like to keep a single copy of the 3 files in one directory and have some <servlet-mapping>s  in web.xml that would "forward" the request from /playoffs to /teams **WITHOUT** the HTTP client being aware of a 'redirect.'  That is, I don't want to issue an HTTP redirect, and WinXP doesn't have file linking like Unix.  Is there some hook in the Default servlet (or other TC-supplied class) that would allow one to do something like the following:
>
>   <servlet>
>     <servlet-name>playoffs</servlet-name>
>     <servlet-class>...DefaultServlet (or whatever)</servlet-class>
>     <init-param>
>       <param-name>FORWARD</param-name>
>       <param-value>/teams</param-value>
>     </init-param>
>   </servlet>
>   <servlet-mapping>
>     <servlet-name>playoffs</servlet-name>
>     <url-pattern>/playoffs/*</url-pattern>
>   </servlet-mapping>
>
>
> The idea is I'm being very lazy and hoping that there is a feature in the default servlet (or other TC-supplied filter/class) that will allow this without me having to write same.  (Of, if someone has some code they'd like to share...)
>
The servlet-entry in web.xml can take a jsp-page parameter instead of a servlet-class
If you define your JSP as a servlet, you can create as many mappings to it as you like.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Linking/forwarding GET requests using Default servlet or other Tomcat feature

Ben Souther
jsp-file that is.


On Wed, 2005-07-27 at 12:36, Ben Souther wrote:

> On Wed, 2005-07-27 at 12:19, Rob Hunt wrote:
> > I'm running a stand-alone (no Apache front-end) TC 5.0.19 server on a WinXP box.  I have a webapp that has a /teams directory that contains gameScores.htm, teamStandings.htm and scoreForm.htm.  I also have a /playoffs directory (can you tell this is a sports-related site?) directory that has the **exact same files**.  
> >
> > Now, I'd like to keep a single copy of the 3 files in one directory and have some <servlet-mapping>s  in web.xml that would "forward" the request from /playoffs to /teams **WITHOUT** the HTTP client being aware of a 'redirect.'  That is, I don't want to issue an HTTP redirect, and WinXP doesn't have file linking like Unix.  Is there some hook in the Default servlet (or other TC-supplied class) that would allow one to do something like the following:
> >
> >   <servlet>
> >     <servlet-name>playoffs</servlet-name>
> >     <servlet-class>...DefaultServlet (or whatever)</servlet-class>
> >     <init-param>
> >       <param-name>FORWARD</param-name>
> >       <param-value>/teams</param-value>
> >     </init-param>
> >   </servlet>
> >   <servlet-mapping>
> >     <servlet-name>playoffs</servlet-name>
> >     <url-pattern>/playoffs/*</url-pattern>
> >   </servlet-mapping>
> >
> >
> > The idea is I'm being very lazy and hoping that there is a feature in the default servlet (or other TC-supplied filter/class) that will allow this without me having to write same.  (Of, if someone has some code they'd like to share...)
> >
> The servlet-entry in web.xml can take a jsp-page parameter instead of a servlet-class
> If you define your JSP as a servlet, you can create as many mappings to it as you like.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
--
Ben Souther
F.W. Davison & Co.

CONFIDENTIALITY NOTICE:

This e-mail message, and any accompanying documents, is for the sole use
of
the intended recipient(s) and may contain confidential and privileged
information.  Any unauthorized review, use, disclosure, distribution or
copying is prohibited.  If you are not the intended recipient, please
contact our office by email or by telephone at (508) 747-7261 and
immediately destroy all copies of the original message.





---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Linking/forwarding GET requests using Default servlet or other Tomcat feature

Rob Hunt
In reply to this post by Rob Hunt
Yes, I know you can make many mappings to a given servlet/jsp, but that's not what I'm asking for.

When an HTTP client requests /playoffs/gameScores.htm, I'm hoping there's some slight-of-hand trick/feature that will cause Tomcat to serve /teams/gameScores.htm WITHOUT a redirect so that it appears to the client that they're getting /playoffs/gameScores.htm.
Reply | Threaded
Open this post in threaded view
|

Re: Linking/forwarding GET requests using Default servlet or other Tomcat feature

Luis Torres
Sounds like something that can be done with frames or iframes

Regards,

Luis

Rob Hunt wrote:

>Yes, I know you can make many mappings to a given servlet/jsp, but that's not what I'm asking for.
>
>When an HTTP client requests /playoffs/gameScores.htm, I'm hoping there's some slight-of-hand trick/feature that will cause Tomcat to serve /teams/gameScores.htm WITHOUT a redirect so that it appears to the client that they're getting /playoffs/gameScores.htm.
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Linking/forwarding GET requests using Default servlet or other Tomcat feature

Ben Souther
Look up the RequestDispatcher:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/RequestDispatcher.html

Server side forwards don't use a redirect



On Wed, 2005-07-27 at 16:18, Luis Torres wrote:

> Sounds like something that can be done with frames or iframes
>
> Regards,
>
> Luis
>
> Rob Hunt wrote:
>
> >Yes, I know you can make many mappings to a given servlet/jsp, but that's not what I'm asking for.
> >
> >When an HTTP client requests /playoffs/gameScores.htm, I'm hoping there's some slight-of-hand trick/feature that will cause Tomcat to serve /teams/gameScores.htm WITHOUT a redirect so that it appears to the client that they're getting /playoffs/gameScores.htm.
> >  
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
--
Ben Souther
F.W. Davison & Co.

CONFIDENTIALITY NOTICE:

This e-mail message, and any accompanying documents, is for the sole use
of
the intended recipient(s) and may contain confidential and privileged
information.  Any unauthorized review, use, disclosure, distribution or
copying is prohibited.  If you are not the intended recipient, please
contact our office by email or by telephone at (508) 747-7261 and
immediately destroy all copies of the original message.





---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Linking/forwarding GET requests using Default servlet or other Tomcat feature

Rob Hunt
In reply to this post by Rob Hunt
Yes, I know that an internal forward would work.  I just didn't want to code/test/debug it.  Yes, I'm being very lazy here; but I hate to reinvent the feature if it already exists and it just seems to me that this is something that probably should already exist (since it can be done in Apache).



Reply | Threaded
Open this post in threaded view
|

Re: Linking/forwarding GET requests using Default servlet or other Tomcat feature

Tim Funk
There is nothing in tomcat which out of the box can do this. But there are
many 3rd party filters (or 3 liners which are easy to write) which can do this.

-Tim

Rob Hunt wrote:

> Yes, I know that an internal forward would work.  I just didn't want to code/test/debug it.  Yes, I'm being very lazy here; but I hate to reinvent the feature if it already exists and it just seems to me that this is something that probably should already exist (since it can be done in Apache).
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]