aspose file tools*
The moose likes JSP and the fly likes Get return value from servlet inside JSP page... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Get return value from servlet inside JSP page..." Watch "Get return value from servlet inside JSP page..." New topic
Author

Get return value from servlet inside JSP page...

Eric Choley
Greenhorn

Joined: Jun 26, 2002
Posts: 2
Hi,
I would like display in a JSP page the result of a servlet (with argments : something like this /servlet/myServlet?id=5).
I try to use the dispatcher.include() but something goes wrong...
Someone has some sample code to use this dispatcher ? or any ideas to get result from servlet ?
Thanks,
Eric


_
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Eric
Can you give us more of a description of what goes wrong? Do you get any exceptions or strange ouput?


Dave
Eric Choley
Greenhorn

Joined: Jun 26, 2002
Posts: 2
Hi Dave,
I m starting with JSP and i have some difficulties to understand this dispatcher and the setAttribute method... i try this code :
<pre>
<%
String servletUri="/servlet/myServlet";
request.setAttribute(servletUri,"action=admin");
// Get the dispatcher from the page context
RequestDispatcher dispatcher = pageContext.getServletContext().getRequestDispatcher(servletUri) ;
if ( dispatcher == null ) {
throw new Exception ( "Unable to find " + servletUri );
}
dispatcher.include (request, response);

HttpSession session_ = pageContext.getSession();

String returnedValue = (String) session_.getAttribute (servletUri);
out.println(returnedValue);
%>
</pre>
Do you have any ideas ? Is there a better way to include result from a servlet with parameters ?
Thanks
Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get return value from servlet inside JSP page...