When I use the Request Dispatcher from within a JSP file, i cam not able to see any of the response written by the called servlet. Should I use any methds to extract the data, or will it automatically be included in the output? Thanks
Why are you using this interface within a JSP ?
It is usually implemented within a servlet to perform either a "forward" or "include" of another URL.
Maybe what you need is to use a getHeader method of request:
String referrer = (String)request.getHeader("referer");
this provides the URI of the caller of the current JSP/servlet.
Usha, you should post the text of your call to the Request Dispatcher so that we can see what you're trying to do. In any case, if what you literally want to do is dynamically include the content generated by a servlet in your JSP, try using the <jsp:include .../> action tag.
Thanks guys. I tried jsp:include, but that doesnt work either
the code is like this:
request.setAttribute("query",new String("select * from tab"));
out.println("Error: Request Dispatcher returned a null");
It doesnt return a null, but doesnt print anything from my servlet ProcessServlet either
Usha, I wrote a small example for myself to see if the request dispatcher include would work, and it seems to work fine. I also tested <jsp:include> and that worked too. I had one difference from you, however: my argument to the request dispatcher specifies a "/servlet/..." prefix, for instance:
RequestDispatcher rq = application.getRequestDispatcher("/servlet/com.whatever.SomeServlet");
and the jsp:include looks like:
<jsp:include page="/servlet/com.whatever.SomeServlet" flush="true"/>
Beyond that, test your servlet to make sure it's actually generating output.