How to forward from a JAX-RS service to JSP?

后端 未结 2 1762
南旧
南旧 2020-12-19 06:05

JBoss Version: 4.2.3GA. This works in apache tomcat 6.0. In JBoss, I had to add the following setting: -Dorg.apache.catalina.STRICT_SERVLET_COMPLIANCE=false to

2条回答
  •  臣服心动
    2020-12-19 06:28

    After getting some help from another location, I realized that I was connecting my JSP and restlet in a funny way, and what I really wanted to do was use a Viewable. This also works way better in JBoss. Here is a summary of what I ended up with:

    import javax.ws.rs.core.Context;
    import javax.ws.rs.Path;
    import javax.ws.rs.GET;
    import com.sun.jersey.api.view.Viewable;
    
    
    @GET
    @Path("/index")
    public Viewable index(
        @Context HttpServletRequest request,
        @Context HttpServletResponse response) throws Exception
    {
      request.setAttribute("key", "value");
      return new Viewable("/jsps/someJsp.jsp", null);
    }
    

提交回复
热议问题