You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mateu Yabar <ma...@foodreg.com> on 2011/05/25 10:53:57 UTC

Context path from ServletContextListener

Hi to all,

I've created a ServletContextListener, which needs to use get the current
context path (as defined in web.xml):

public class UpdateExecutionStartContextListener implements
javax.servlet.ServletContextListener{
    @Override
    public void contextInitialized(ServletContextEvent arg0) {
        String conextPath=¿?
    }
       (...)

Is there any way to obtain this?

Iv'e seen in
http://www.jcp.org/aboutJava/communityprocess/maintenance/jsr154/servlet-2.5_MR2.htmlthat
in servlet 2.5 it will exists the method
ServletContext.getServletPath(), however with my tomcat6-Java6 this method
does not exist yet.

Thanks

Re: Context path from ServletContextListener

Posted by Mateu Yabar <ma...@foodreg.com>.
Sorry, I don't see how I did not see it:
arg0.getServletContext().getContextPath()

On 25 May 2011 10:53, Mateu Yabar <ma...@foodreg.com> wrote:

> Hi to all,
>
> I've created a ServletContextListener, which needs to use get the current
> context path (as defined in web.xml):
>
> public class UpdateExecutionStartContextListener implements
> javax.servlet.ServletContextListener{
>     @Override
>     public void contextInitialized(ServletContextEvent arg0) {
>         String conextPath=¿?
>     }
>        (...)
>
> Is there any way to obtain this?
>
> Iv'e seen in
> http://www.jcp.org/aboutJava/communityprocess/maintenance/jsr154/servlet-2.5_MR2.htmlthat in servlet 2.5 it will exists the method
> ServletContext.getServletPath(), however with my tomcat6-Java6 this method
> does not exist yet.
>
> Thanks
>
>
>