gudii9
asked on
rest example
hi,
trying below example
https://www.mkyong.com/webservices/jax-rs/jersey-hello-world-example/
HTTP Status 404 – Not Found
Type Status Report
Message /RESTfulExample/
getting below error
http://localhost:8080/RESTfulExample/
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/8.5.23
please advise
trying below example
https://www.mkyong.com/webservices/jax-rs/jersey-hello-world-example/
HTTP Status 404 – Not Found
Type Status Report
Message /RESTfulExample/
getting below error
http://localhost:8080/RESTfulExample/
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/8.5.23
please advise
ASKER
projectURL/rest/hello/
http://localhost:8080/RESTfulExample/rest/hello
is project url here is
http://localhost:8080/RESTfulExample??
how it is mapping?
http://localhost:8080/RESTfulExample/rest/hello
is project url here is
http://localhost:8080/RESTfulExample??
how it is mapping?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Restful Web Application</display-name>
<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.mkyong.rest</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
i see web.xml as above pointing rest to jersey implementation servleti see resource as below
package com.mkyong.rest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
@Path("/hello")
public class HelloWorldService {
@GET
@Path("/{param}")
public Response getMsg(@PathParam("param") String msg) {
String output = "Jersey say : " + msg;
return Response.status(200).entity(output).build();
}
}
ASKER
i may have to keep index file when i load project on server
http://localhost:8080/RESTfulExample
http://localhost:8080/RESTfulExample
ASKER
above gave
Jersey say : gp