On Mar 10, 2009, at 9:14 AM, Саид Асадуллин wrote:
>> Yes, what version of Jersey are you using? and what Web container are
>> you using?
>>
>> Jersey can support:
>>
>> @Path("/") public class Slash { ... }
>>
>> @Path("/{projects}") public class Projects { ... }
>>
>>
>> So that
>>
>> http://localhost/webapp/resource/
>>
>> maps to the root resource Slash. And,
>>
>> http://localhost/webapp/resource/1234
>>
>> maps to the root resource Projects.
>>
>>
>> However as Naresh and I observe:
>>
>> http://localhost/webapp/resource
>>
>> maps to the root resource Projects. Which is definitely a bug,
>> possibly in servlet as the URI pattern "resources/*" does not match.
>> Naresh could you log an issue with Jersey so we do not forget to
>> investigate further?
>>
>> Paul.
>
> Thanks Paul, thanks Naresh
>
> Im trying jersey 1.0.2 and 1.0.3 on IBM Websphere AS 7.0.0.1.
Unfortunately i do not have time to investigate issues on WebSphere.
I think the problem could be due to the way the base URI is determined
(see code below for theServletContainer.service method. You would not
believe how hard this is to obtain the base URI using Servlet!! and i
had to work around a number of bugs in implementations.
It would be of great help if you could try debugging the
ServletContainer.service method on WebSphere? and reporting back how
things behave?
Paul.
@Override
public void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
/**
* There is an annoying edge case where the service method is
* invoked for the case when the URI is equal to the
deployment URL
* minus the '/', for example
http://locahost:8080/HelloWorldWebApp
*/
if (request.getPathInfo() != null &&
request.getPathInfo().equals("/") && !
request.getRequestURI().endsWith("/")) {
response.setStatus(404);
return;
}
/**
* The HttpServletRequest.getRequestURL() contains the
complete URI
* minus the query and fragment components.
*/
UriBuilder absoluteUriBuilder = UriBuilder.fromUri(
request.getRequestURL().toString());
/**
* The HttpServletRequest.getPathInfo() and
* HttpServletRequest.getServletPath() are in decoded form.
*
* On some servlet implementations the getPathInfo() removed
* contiguous '/' characters. This is problematic if URIs
* are embedded, for example as the last path segment.
* We need to work around this and not use getPathInfo
* for the decodedPath.
*/
final String decodedBasePath = (request.getPathInfo() != null)
? request.getContextPath() + request.getServletPath()
+ "/"
: request.getContextPath() + "/";
final String encodedBasePath =
UriComponent.encode(decodedBasePath,
UriComponent.Type.PATH);
if (!decodedBasePath.equals(encodedBasePath)) {
throw new ContainerException("The servlet context path
and/or the " +
"servlet path contain characters that are percent
enocded");
}
final URI baseUri =
absoluteUriBuilder.replacePath(encodedBasePath).
build();
String queryParameters = request.getQueryString();
if (queryParameters == null) {
queryParameters = "";
}
final URI requestUri =
absoluteUriBuilder.replacePath(request.getRequestURI()).
replaceQuery(queryParameters).
build();
service(baseUri, requestUri, request, response);
}
> All
> works perfectly exept the @Path("/").
> http://localhost/webapp/resource/ and http://localhost/webapp/resource
> in my case maps to Project resource, and
> uriInfo.getPathParameters().getFirst("project") returns "resource".
>
> Best regards,
> Saiid.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>