I have a servlet A which calls another servlet B. B throws an html o/p. how can servlet A catch the o/p sent by servlet B?
nirmal baba
Greenhorn
Joined: Apr 06, 2001
Posts: 10
posted
0
Hi U will have to use the RequestDispatcher's include(req,res) method in the calling servlet(servlet A in ur case) which then will include the output of the called servlet(servlet B in ur case) at the point of inclusion!! Only thing that u have to keep in mind that u should use version2.1 and later (since RequestDispatcher got introduced in 2.1 only) for ur servlet class files to compile successfully Kindly keep me informed if this explanation helped u sort out ur problem!! Wish u all the best Nirmal
Sachin Deshpande
Greenhorn
Joined: Jan 31, 2001
Posts: 25
posted
0
Do I have to add data(or an object) that i want to pass in the req obj? and then do i just call B by the sendRedirect method as I have been doing???
maha anna
Ranch Hand
Joined: Jan 31, 2000
Posts: 1467
posted
0
Sachin, A sample code in your calling sevlet which is 'Servlet A' could be
regds maha anna
prabhatis
Greenhorn
Joined: Apr 07, 2001
Posts: 18
posted
0
try this . String strUrl = URLEncoder.encode("path of ur servlet something like http:\\adress\\servlet\servletname\"); try { URL u = new URL(strUrl); InputStream i = u.openStream(); //now u have inputstream .. u can u anything u like ... } catch(Exception e) {} hope it might help