Suppose we have some project with next structure:
web articles main.jsp sidearts.jsp central.jsp forum main.jsp css js WEB-INF web.xml
Note that we don't have front controller at this point yet.
After deploying with some facet (let it be 'asdf') we can access our pages using next URLs:
http://localhost:8080/asdf/articles/main.jsp http://localhost:8080/asdf/forum/main.jsp and so on..
main.jsp generates some html and includes sidearts.jsp (by means of jstl c:import or any other way)
And what will happen after adding front controller?
Suppose we have servlet ArticlesController which is responsible for dispatching
some requests and which has next mapping:
<servlet>
<servlet-name>ArtsController</servlet-name>
<servlet-class>org.forstackoverflow.ArticlesController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ArtsController</servlet-name>
<url-pattern>/articles/*</url-pattern>
</servlet-mapping>
Now when we request URL http://localhost:8080/asdf/articles/main
, ArticlesController handles this request and try to include articles/main.jsp. And at this point infinity cycle starts because /articles/* is mapped to ArtsController.
What is the correct solution of described problem?
My variants are:
1) make mappings for all jsp-files (I don't think that it is acceptible)
2) change directories names (articles->arts); but then we get lots of new URLs (like http://localhost:8080/asdf/arts/main.jsp
) and I think that it can be a source of bugs.