users@jersey.java.net

Re: [Jersey] XSLT and Jersey

From: Steve Mactaggart <steve_at_whitesquaresoft.com>
Date: Mon, 19 Jan 2009 16:24:09 +1100

Thanks for the pointers and I have now used a servlet filter to solve this
issue and it works great. My only problem now is that when this filter is
enabled Jersey doesn't seem to pull in the POST content.
My filter is attached below, it seems that no matter what Jersey is not
getting the post information.
If I disable this filter it work, but with it enabled the content received
is and empty string.

My Jersey method looks like:

@POST
@Path("/create")
public String createPOST(String content) {
log.info("createPOST " + uriInfo.getPath() + ", content = " + content);
try
{
return renderResponse(invokeCreate(content));
} catch (Throwable e) {
log.error(e.getMessage(), e);
XMLErrors errs2 = new XMLErrors();
errs2.add(new XMLError("general", e.getMessage()));
return renderResponse(errs2);
}
}


Any ideas?

My filter is:
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// String contentType;
String styleSheet;
 String type = request.getParameter("_xslt");
String element = ((HttpServletRequest)request).getRequestURI();
 if (element.startsWith("/")) {
element = element.substring(1);
}
 if (element.indexOf('/') > -1) {
element = element.substring(0, element.indexOf('/'));
}
 Reader styleSheetStream = XSLTManager.getStylesheet(element, type);
 if (styleSheetStream == null) {
chain.doFilter(request, response);
}
else {
// do the request, get back the content and do the XSLT transform
// this is removed for brevity, and should not be called during my post
actions as I don't have an "xslt" query parameter
}

On Thu, Jan 8, 2009 at 7:56 AM, Steve Mactaggart
<steve_at_whitesquaresoft.com>wrote:

> Sorry about the double posting, I was not receiving users@ emails and so
> re-registered. I did a search on the list even and assumed the post didn't
> make it due to my registration status.
>
> thanks for the pointers, and I'll look into the use of filters.
>
> Steve
>
>
> On Wed, Jan 7, 2009 at 11:10 PM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
>
>> Hi Steve,
>>
>> I replied to you email yesterday:
>>
>> http://markmail.org/search/?q=list
>> %3Anet.java.dev.jersey.users#query:list%3Anet.java.dev.jersey.users+page:1+mid:sk7sb73cfuexkbiv+state:results
>>
>> Paul.
>>
>>
>> On Jan 7, 2009, at 1:06 PM, Steve Mactaggart wrote:
>>
>> Hi all,
>>>
>>> I am loving the ease of use of Jersey to expose simple XML web services,
>>> I have a quick question about being able to do server side transforms on the
>>> data using XSLT.
>>>
>>> We want to have a standard document format for accessing some of our
>>> data, but also the ability to pass a flag to the web service that allows us
>>> to turn on XSLT or some sort of processing that will modify the XML output.
>>>
>>> We don't want to have multiple data models, as they are close to the
>>> same, we just would like to do some post (jaxb) processing on the XML to
>>> make minor changes.
>>>
>>> Is there any way to do this inside the Jersey framework?
>>>
>>> Thank,
>>> Steve
>>>
>>>
>>
>> --
>> This message has been scanned for viruses and
>> dangerous content by MailScanner, and is
>> believed to be clean.
>>
>>
>