1

In Eclipse I can select a servlet from a web application, and choose "Run As -> Run on Server" from the context menu. One minor problem is that a browser is opened with a wrong url. For example, I have written a servlet similar to:

package mypackage;

@WebServlet("/append")
public class AppendTest extends HttpServlet {
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) ... 
...
}

then I can test it in a browser with a URL similar to: http://127.0.0.1:8080/mywebapp/append

But when I choose to run the servlet as explained above, the browser is directed to:

http://127.0.0.1:8080/mywebapp/servlet/mypackage/AppendTest

Although this is a minor problem for testing the application, in fact this issue does not let me debug it, since when I select "Debug As -> Debug on Server", the same problem happens, and the debugger stops after the 404 http status answer (if I correct the URL after the 404 status, the debugger is not active anymore).

The servlet container I am using is JBoss.

Thanks for any help.

UPDATE:

I was not able to debug since the server was not correctly configured in Eclipse (configured as managed externally instead of by Eclipse, thanks for the hint @CarlosGavidia).

This apparently solves the biggest problem. If someone knows how to make Eclipse to open the right URL of the servlet at once instead of myself annoyingly correcting the url every time I run/debug it I will be thankful.

I am starting to think that this is an Eclipse bug. If I explicitly declare the URL pattern in the web.xml then eclipse will use the correct url. That means that the value of the WebServlet annotation indicating that URL when writing the servlet class is just ignored by eclipse when running/debugging the application :(

4

0 回答 0