|
Re: Eclipse/Tomcat7: application context root reloading returns 404 [message #1058561 is a reply to message #1058129] |
Tue, 14 May 2013 13:10 |
Larry Isaacs Messages: 1354 Registered: July 2009 |
Senior Member |
|
|
On 5/12/2013 7:27 PM, Yang Zheng wrote:
> I have a servlet which is mapped to application context root using the
> "" string: So when I hit the url localhost/myapp/, I can see "This is
> ROOT!" in the browser. So far so good.
>
> But if I modify something, say changing the String This is ROOT!! to
> ROOT!! and save the file in eclipse. Eclipse will take a couple of
> seconds to reload the context. Now if i hit the same url, a 404 page is
> displayed while all other pages still work fine. Only the root mapping
> is broken. So I redeploy (eclipse's "run on server") the app and the
> root mapping is back again. Any ideas on how can I fix this?
>
> @WebServlet("")
> public class Root extends HttpServlet {
> private static final long serialVersionUID = 1L;
>
> protected void doGet(HttpServletRequest request, HttpServletResponse
> response) throws ServletException, IOException {
> response.getWriter().println("This is ROOT!!");
> }
>
> protected void doPost(HttpServletRequest request,
> HttpServletResponse response) throws ServletException, IOException {
> // TODO Auto-generated method stub
> }
>
> }
Since this is Tomcat behavior, you may have better luck asking on the
tomcat-users mailing list[1], if you haven't already. I'm not sure what
exactly is different about reloading as opposed to restarting, but if
any mapping was going to have a problem with the difference, a mapping
for "" would like be the one. This behavior would seem to be a bug.
I'm not an expert on the Servlet spec, but I'm not sure what it
guarantees with respect to what "" matches as opposed to the default
servlet which is mapped to "/". I can see "" being a tricky mapping to
handle.
Cheers,
Larry
[1] http://tomcat.apache.org/lists.html#tomcat-users
|
|
|
Powered by
FUDForum. Page generated in 0.02916 seconds