2

I am not able to redirect to html page with data in jersey . Below is the code

@POST
    @Path("/vendorAuthentication")
    @Consumes({MediaType.APPLICATION_JSON})
    @Produces("application/json")
    public Response vendorAuthentication(final VendorAuthenticationRequest  vendorAuthenticationRequest) {

        if(isVendorAuthenticated == true)       
        {
            Map<String, Object> map = new HashMap<String, Object>();          
             map.put("vendorId", "V111");
             map.put("vendorName","XXX")             
             return Response.ok(new Viewable("/page2", map)).build();
        }


    }

After successful authentication of vendor, url should redirected to page2 with some data.But its not happening.Also I checked the brower(Mozilla Firefox) for debugging, in browser it shows the code of next(i.e. page2) page code.But it will not redirect to page2.

Below is my web.xml

<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.abc.rest</param-value>
        </init-param>
        <init-param>
        <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
        <param-value>true</param-value>
    </init-param>
   <init-param>
        <param-name>com.sun.jersey.config.property.JSPTemplatesBasePath</param-name>
        <param-value>/WEB-INF/jsp</param-value>
    </init-param>
    <init-param>
        <param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name>
        <param-value>/(WEB-INF/jsp)/.*</param-value>
    </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
<welcome-file-list>
 <welcome-file>/WEB-INF/jsp/Login.jsp</welcome-file> 
</welcome-file-list>
    <servlet-mapping>
        <servlet-name>jersey-serlvet</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
Vaibs
  • 1,546
  • 9
  • 31
  • You should be following the [Post/Redirect/Get](https://en.wikipedia.org/wiki/Post/Redirect/Get) pattern. Return a _real_ redirect, and send the parameters in query string. See [here](http://stackoverflow.com/a/25332038/2587435) – Paul Samsotha Jul 08 '16 at 14:50
  • As suggested by @peeskillet, follow that link to make redirection & then in response maybe set cookie with some token then on page2 load write one script to load the vendor id,name by sending the token to verify that it is authenticated. So basically there would be two rest services one to redirect & set cookie of token & second to fetch the vendor id,name based on the token given in cookie. – vinayakj Jul 08 '16 at 17:00

0 Answers0