I am just Rest API concept with hello world
program. I'm following some tutorial videos and trying the same program But I'm not getting the expected result.
Here is my Book.java
package com.book;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/book") //URI
public class Book {
@GET
@Produces(MediaType.TEXT_XML)
public String sayHelloXML() {
String response = "<?xml version='1.0'?>" + "<hello>Hello World</hello>";
return response;
}
}
and the web.xml
<?xml version="1.0" encoding="UTF-8"?>
<element>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>WSdemo</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>JAVA WS</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>book</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAVA WS</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
</element>
And I'm using Tomcat v8.0
server.
But as I run the application, I am getting out put as
Can somebody give me key ideas for learning the concept of RESTfull web service?