You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Michael Taylor <mt...@emeraldcave.net> on 2000/07/21 01:29:44 UTC

Can you get the webapp context path from the javax.servlet API?

I had some really big problems with the implementation of jsp:include failing
from a JSP to a servlet, so I wrote my own include tag.

I need to know if there is a way to get the context path from without creating
a dependency on tomcat.  If my web-app context is /foo and I want to convert a
URL relative to the current context back into an external URL with the full
syntax, then I have to make the following call at this point:

((org.apache.tomcat.core.ServletContextFacade)pageContext.getServletContext()).getRealContext().getPath();

I also think I ocould do it with 

((org.apache.tomcat.core.HttpServletRequestFacade)RequestpageContext.getRequest()).getRealRequest().getContext().getPath();

It seems to me that this is a simple enough thing to get the /foo portion of
the path back out of the Servlet engine, but I can't find this anywhere.

Thanks for the help,

Mike Taylor
mdt@qad.com

Re: Can you get the webapp context path from the javax.servlet API?

Posted by Michael Taylor <mt...@emeraldcave.net>.
Please forgive me.  I have no idea how I missed that Craig.  I must be
tired from working too hard.

Cheers,

Mike

On Thu, 20 Jul 2000, Craig R. McClanahan wrote:
> Is something wrong with request.getContextPath() for this?  It's part of the standard servlet 2.2 API.
> 
> Craig

Re: Can you get the webapp context path from the javax.servlet API?

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Is something wrong with request.getContextPath() for this?  It's part of the standard servlet 2.2 API.

Craig


Michael Taylor wrote:

> I had some really big problems with the implementation of jsp:include failing
> from a JSP to a servlet, so I wrote my own include tag.
>
> I need to know if there is a way to get the context path from without creating
> a dependency on tomcat.  If my web-app context is /foo and I want to convert a
> URL relative to the current context back into an external URL with the full
> syntax, then I have to make the following call at this point:
>
> ((org.apache.tomcat.core.ServletContextFacade)pageContext.getServletContext()).getRealContext().getPath();
>
> I also think I ocould do it with
>
> ((org.apache.tomcat.core.HttpServletRequestFacade)RequestpageContext.getRequest()).getRealRequest().getContext().getPath();
>
> It seems to me that this is a simple enough thing to get the /foo portion of
> the path back out of the Servlet engine, but I can't find this anywhere.
>
> Thanks for the help,
>
> Mike Taylor
> mdt@qad.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org