My example is using the ImplicitViewable configuration feature (see WEB-INF/web.xml
) and implicit viewables approach, where the JSP pages are mapped via being placed at the right
path corresponding to the appropriate resource package name. It doesn't work. What should I do as an extra?
if ${it.name}
is written into jsp file also resource class has its private name variable then nothing happens. I couldn't achieve the connection.
here is web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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">
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.feature.Redirect</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.feature.ImplicitViewables</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>ServletAdaptor</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ServletAdaptor</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>com/sun/jersey/samples/bookstore/resources/Hotelstore/index.jsp</welcome-file>
</welcome-file-list>
</web-app>
here is hotelstore.java inside of the package com/sun/jersey/samples/hotelstore/resources/
@Path("/")
@Singleton
public class Hotelstore {
private final Map<String, Hotelitem> items = new TreeMap<String, Hotelitem>();
private String name;
public Hotelstore() {
setName("Otel sheriton");
getItems().put("1", new Hotelitem("Sheriton", "Maslak","Big boss", new Room[]{
new Room(1,"Cedric","dolu"),
new Room(2,"Eigner","dolu"),
new Room(3,"Deli","dolu"),
new Room(4,"","bos")
}));
}
@Path("Hotelitems/{itemid}/")
public Hotelitem getItem(@PathParam("itemid") String itemid) {
Hotelitem i = getItems().get(itemid);
if (i == null)
throw new NotFoundException("there is no room number"+itemid);
return i;
}
public long getSystemTime() {
return System.currentTimeMillis();
}
public Map<String, Hotelitem> getItems() {
return items;
}
getter setter for name.
......
}