tags:

views:

36

answers:

1

How do I pass parameters from ServletOne to ServletTwo using a HTTP POST through URL?

For example: http://localhost/ServletOne?username=test

If the passing of parameters is successful, a JSON text will appear in the JSP page.

+1  A: 

If ServletOne and ServletTwo are running on the same server you can just use a foward. ServletTwo will then have access to the query parameters from ServletOne. Is that what you are asking?

For example:

protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {

    req.getRequestDispatcher("ServletTwo").forward(req,res);

}

If ServletOne and ServletTwo are running on different servers then you will have to code an HTTP POST request in ServletOne to call ServletTwo.

DMKing