REST API with web application(JSP,Servlets) – Education Career Blog

I have one normal servlet and one jersey specific REST related servlet i.e.ServletContainer configured in web.xml.
Case 1 –
Url pattern for normal servlet is “/login”
Url pattern for other REST servlet is “/
In this case all request will got REST servlet. Request for login also goes to tht Servlet only.
Case 2 –
If Url pattern for REST servlet changed to “/rest/
” (which root path of my test resource class)
And Url pattern for normal servlet as it was “/login”
Only normal request for /login works, but any REST requests doesn’t work.

Can anyone help me in this??


My best guess given what you’ve told us (I’m assuming you’re running two different webapps):

Set contexts in your tomcat configuration server.xml

<Context path="" docBase="/yourworkspace/project-webapp/docs/" ... />
<Context path="/rest" docBase="/yourworkspace/project-rest/docs/" ... />

Application Mapping

In rest-web.xml (your jersey web application)


In jsp-web.xml (your jsp web application)


In your Jersey application, your URL mapping should start on /


public interface CarResource {

  Car getCar(@PathParam("carId") Long carId);

should handle GET requests.


What do you want to achieve ? In case 2 try to change it to this /rest/*.

Leave a Comment