views:

36

answers:

2

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??

A: 

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

kukudas
Hey friend sorry, I had actually tried the same /res/*.
Parag
I just want to call rest api when am using rest uri created.
Parag
N i want to call normal servlet when am using url as /login.
Parag
if you specifie the url pattern like this: /rest/* and and have a class wich is annoted by this: @Path( "/test" ) then the following call: http:// {host}:{port}/{appName}/rest/test should invoke the service.
kukudas
Thanks a lot man................!!!!! It worked....!! This small example cleared the confusion...!! :-)
Parag
great, i'm glad i could help you.
kukudas
A: 

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)

<servlet-mapping>
    <servlet-name>project-rest</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

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

<servlet-mapping>
    <servlet-name>project-webapp</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

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

Example:

@Path("/car")
@Named("carResource")
public interface CarResource {

  @GET
  @Path("{carId}")
  @Consumes("text/plain")
  @Produces("application/xml")
  Car getCar(@PathParam("carId") Long carId);

should handle GET http://domain.org/rest/car/42 requests.

Brian Clozel