• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Get return value from servlet inside JSP page...

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric
Can you give us more of a description of what goes wrong? Do you get any exceptions or strange ouput?
 
Eric Choley
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic