REST API DESIGN – Getting a resource through REST with different parameters but same url pattern

In my experience, GET /users/{id} GET /users/email/{email} is the most common approach. I would also expect the methods to return a 404 Not Found if a user doesn’t exist with the provided id or email. I wouldn’t be surprised to see GET /users/id/{id}, either (though in my opinion, it is redundant). Comments on the other … Read more

Mapping a specific servlet to be the default servlet in Tomcat

This should be useful to you. From the Java™ Servlet Specification Version 3.1 (JSR 340) Chapter 12. Mapping Requests to Servlets 12.2 Specification of Mappings In the Web application deployment descriptor, the following syntax is used to define mappings: A string beginning with a / character and ending with a /* suffix is used for … Read more

What is the significance of url-pattern in web.xml and how to configure servlet?

url-pattern is used in web.xml to map your servlet to specific URL. Please see below xml code, similar code you may find in your web.xml configuration file. <servlet> <servlet-name>AddPhotoServlet</servlet-name> //servlet name <servlet-class>upload.AddPhotoServlet</servlet-class> //servlet class </servlet> <servlet-mapping> <servlet-name>AddPhotoServlet</servlet-name> //servlet name <url-pattern>/AddPhotoServlet</url-pattern> //how it should appear </servlet-mapping> If you change url-pattern of AddPhotoServlet from /AddPhotoServlet to /MyUrl. … Read more

Sometimes I see JSF URL is *.jsf, sometimes *.xhtml and sometimes /faces/*. Why?

The .jsf extension is where the FacesServlet is during the JSF 1.2 period often mapped on in the web.xml. <servlet-mapping> <servlet-name>facesServlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> The .xhtml extension is of the actual Facelets file as you’ve physically placed in the webcontent of your webapp, e.g. Webapp/WebContent/page.xhtml. If you invoke this page with the .jsf extension, e.g. http://localhost:8080/webapp/page.jsf … Read more

Difference between / and /* in servlet mapping url pattern

<url-pattern>/*</url-pattern> The /* on a servlet overrides all other servlets, including all servlets provided by the servletcontainer such as the default servlet and the JSP servlet. Whatever request you fire, it will end up in that servlet. This is thus a bad URL pattern for servlets. Usually, you’d like to use /* on a Filter … Read more