2

I'm working on existing JSF application i need to implement rest service in this application so user can also consume data using rest api from existing jsf application.

I have tried

How can I integrate JSF with REST? but no response made on this question.

Calling REST service in my JSF application here requirement is opposite from my case.

How to redirect to JSF page from JAX-RS method? with this i have same issue.

I have follow this https://www.mkyong.com/webservices/jax-rs/restful-java-client-with-jersey-client/

downloaded jar of jersey-client-1.19.4.jar, added to library creating class

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/rest")
public class JSONService {

@GET
@Path("/get")
@Produces(MediaType.APPLICATION_JSON)
public void test(@Context HttpServletRequest request, @Context HttpServletResponse response)
        throws IOException {
    String myJsfPage = "i am here";
    response.getWriter().write(myJsfPage);
}
} 

but it gives me 404 page not found, please help me.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Nitin Upadhyay
  • 113
  • 1
  • 15
  • 404 from you browser? Can you past in the request and response in you question? – Jocke May 22 '19 at 07:04
  • Hi @Jocke, i have updated code snippets please check. – Nitin Upadhyay May 22 '19 at 07:11
  • How did you connect `JSONService`? – Ori Marko May 22 '19 at 07:14
  • I'm new to jersey, i have just follow above link to inject rest service using jersey in existing JSF project. – Nitin Upadhyay May 22 '19 at 07:16
  • 1
    "inject rest service in JSF" is a weird statement. And there is no such thing as 'a jsf application". JSF is the ui frontend to an application. And what you try in your code is strange. Nothing JSF related in there. Try to get a basic jax-rs example to work and clarify your problem afterwards. In addition read https://stackoverflow.com/questions/29982657. And if your what you want to achieve is https://stackoverflow.com/questions/19481834 then you have to fix your 404 problem first which is totally not JSF related but pure jax0rs – Kukeltje May 22 '19 at 18:42

0 Answers0