You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Marius Preuten <ma...@preuten.com> on 2007/07/05 12:12:55 UTC

Using the Tomcat API to Change the Context

I'm trying to write a Servlet which adds a Mapping on an existing 
Servlet-Class to ists own Context.
Is this possible or are there any restrictions ?

I tried this, but there wasn't a result:
.....
public class Index extends HttpServlet implements ContainerServlet {
............
    protected void doGet(HttpServletRequest request,HttpServletResponse 
response) throws ServletException, IOException {
        PrintWriter out = response.getWriter();
        Context child = (Context) host.findChild("/Admin");     //<-- 
ists not the default admin-app
        out.println(child.getName()+"<br />");       //<-- Exists
        child.addServletMapping("/test.html", "Index");           
//<--tries to map his own servlet class to a new url
    }
.......
}


If i go to http://myserver:8080/Admin/index.html there is no error or 
something,
but if i try http://myserver:8080/Admin/test.html i get a 404.
I use Tomcat 6.0.13 on WinXP or Debian4.0 if that counts.

If someone knows a good tutorial about this stuff, it would be very 
nice, because i can't find any on the web.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org