Invoke a servlet from a servlet

September 3, 2009 · Posted in Uncategorized 

There are couple of ways to do so:

  1. Send a HTTP request
    To invoke a servlet that requires authentication, in addition to creating the URL object, you need to pass authentication cookies too.

    URL url = new URL("http://blah");
    URLConnection con = url.openConnection();
    con.setRequestProperty("Cookie", request.getHeader("Cookie"));
    con.connect();
  2. RequestDispatcher
  3. Send a redirect

Comments

Leave a Reply




  • Calendar

    September 2009
    M T W T F S S
    « Jul   Jan »
     123456
    78910111213
    14151617181920
    21222324252627
    282930