You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Daniel Watrous <dw...@gmail.com> on 2005/04/25 19:40:33 UTC

context path question

Hello,

I am have written some filters for a shopcart application.  I intend
for parts of this applicaiton to be reused in other web applications
by including it as a JAR file.

For authentication I have the file AdministratorAuthFilter, which
checks for a session value indicating that the user has logged in. 
The trouble comes with the following line:

response.sendRedirect("/simplecart/AdministratorLogin.do");

My development application is simplecart and so when I deploy to
tomcat I have a URL like "http://localhost:8080/simplecart/" which
serves as my root.  If I include this filter in another application as
part of a JAR that application will end up with another root, such as
"http://localhost:8080/mycart/".  So the line above in my filter that
includes the literal "simplecart" breaks.

I have searched for something related to the context or context path.
All suggestions appreciated.

--
DW

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: context path question

Posted by Daniel Watrous <dw...@gmail.com>.
Thanks.  That did the trick!

DW

On 4/25/05, Tim Funk <fu...@joedog.org> wrote:
> Use HttpServeletRequest.getContextPath() to get the context path.
> 
> -Tim
> 
> Daniel Watrous wrote:
> 
> > Hello,
> >
> > I am have written some filters for a shopcart application.  I intend
> > for parts of this applicaiton to be reused in other web applications
> > by including it as a JAR file.
> >
> > For authentication I have the file AdministratorAuthFilter, which
> > checks for a session value indicating that the user has logged in.
> > The trouble comes with the following line:
> >
> > response.sendRedirect("/simplecart/AdministratorLogin.do");
> >
> > My development application is simplecart and so when I deploy to
> > tomcat I have a URL like "http://localhost:8080/simplecart/" which
> > serves as my root.  If I include this filter in another application as
> > part of a JAR that application will end up with another root, such as
> > "http://localhost:8080/mycart/".  So the line above in my filter that
> > includes the literal "simplecart" breaks.
> >
> > I have searched for something related to the context or context path.
> > All suggestions appreciated.
> >
> 
> ---------------------------------------------------------------------
> 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: context path question

Posted by Tim Funk <fu...@joedog.org>.
Use HttpServeletRequest.getContextPath() to get the context path.

-Tim

Daniel Watrous wrote:

> Hello,
> 
> I am have written some filters for a shopcart application.  I intend
> for parts of this applicaiton to be reused in other web applications
> by including it as a JAR file.
> 
> For authentication I have the file AdministratorAuthFilter, which
> checks for a session value indicating that the user has logged in. 
> The trouble comes with the following line:
> 
> response.sendRedirect("/simplecart/AdministratorLogin.do");
> 
> My development application is simplecart and so when I deploy to
> tomcat I have a URL like "http://localhost:8080/simplecart/" which
> serves as my root.  If I include this filter in another application as
> part of a JAR that application will end up with another root, such as
> "http://localhost:8080/mycart/".  So the line above in my filter that
> includes the literal "simplecart" breaks.
> 
> I have searched for something related to the context or context path.
> All suggestions appreciated.
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org