简体   繁体   中英

How to forward request from rest webservice to a servlet

I want to know is there any way to forward servlet request and response from a rest webservice to a servlet.. I have a servlet on remote server from which i am calling webservice to get the request params and then i want it to forward to another servlet from that webservice.I tried some code but it does not work. Please give me suggestions if anyone had worked on it.

this is my rest web code snippet

@GET
    @Path("/test")
    public void requestToTelkom(@Context HttpServletRequest request,@Context HttpServletResponse response ) {

         try {



        // the request object is printed successfully
        System.out.println(request);



// when i try to forward like this i get exceptions
         RequestDispatcher rd = request
                 .getRequestDispatcher("BypassServlet");

            rd.forward(request, response);
        } catch (ServletException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

I got this exception with above code

 UT010023: Request io.undertow.servlet.spec.HttpServletRequestImpl@53b21177 was not original or a wrapper

For future visitors looking for a solution. This is what helped me on a jboss eap 7 server..add allow-non-standard-wrappers="true" to your standalone.xml file in the servlet container like this:

<servlet-container name="default" allow-non-standard-wrappers="true">
    <jsp-config/>
    <websockets/>
</servlet-container>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM