Servlet magically invoked twice

Hey all

I have this servlet which picks up all requests against a certain URI (/users/*) - parses the URI and then redirects to a JSP along with a certain parameter. When debugging the servlet I've found that it is invoked twice, the first time is fully valid and it parses the username and redirects to the JSP with a correct parameter. The second (and unnecessary) time it is invoked it doesn't parse the URI but the filename of the CSS file which the JSP page uses. So the URI the second time is something like "web-app/include/style.css". Any ideas why this is happening?

protectedvoid doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException, IOException{

String uri = req.getRequestURI();

String username =new String();

int slash = uri.lastIndexOf(("user/"));

if(slash != -1){

username = uri.substring(slash + 5);

//If username exists

if(appManager.getPersonByUsername(username) !=null){

dispatcher = getServletContext().

getRequestDispatcher("/publicFiles.jsp?username=" + username);

dispatcher.forward(req, res);

return;

}

}else

dispatcher = getServletContext().

getRequestDispatcher("/index.jsp");

dispatcher.forward(req, res);

}

Thanks!

[1899 byte] By [syncroa] at [2007-10-3 1:09:31]
# 1
This may be a problem with your servlet mapping. Check your web.xml file
LRMKa at 2007-7-14 18:06:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...