I have a JAX-RS based web application that I have working correctly. The development environment is Jetty 9, Maven 3.0.4, and JBoss RESTeasy.
I have a method in a public class resource /login
(reachable at http://somedomain/login
, tested, working correctly) that looks like this (see this SO post):
@Path("/login")
public class LoginResource {
@GET
@Path ("/silly")
@Produces ("text/html")
public void sillier (@Context HttpServletRequest request, @Context HttpServletResponse response) throws ServletException, IOException
{
request.getRequestDispatcher ("/Project/hello.jsp").forward (request, response);
}
}
The file /Project/hello.jsp
is loadable on a browser (at http://somedomain/Project/hello.jsp
) when not called by the method sillier
above, and the contents of hello.jsp
are as follows.
<HTML><BODY>
Hello! The time is now <%= new java.util.Date() %>
</BODY></HTML>
This code does what you would expect--print out the current time in the browser.
When I call http://somedomain/login/silly
, though, I see the following issue:
Unable to find contextual data of type: javax.servlet.http.HttpServletRequest
What am I missing? Is this some configuration in pom.xml
and/or web.xml
I am missing?
My web.xml
is below:
Archetype Created Web Application
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.sonny.project.web.App</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>