• 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

How to use the include() command in JSP

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to include the output from another URL in my JSP.
This works fine if I write the syntax like and the output of the second servlet is embedded in the jsp page.
*** first case ***
<html>
<head>
<title>Test Page</title>
</head>
<body>
<% getServletConfig().getServletContext().getRequestDispatcher("servlet/com.mypack.ExternalOutput").include(request,response); %>

</body>
</html>
*** end ***
But, if I want to pass some parameters to another servlet in the form of URL rewriting then there is a problem like
*** second case ***
<html>
<head>
<title>Test Page</title>
</head>
<body>
<% getServletConfig().getServletContext().getRequestDispatcher("servlet/com.mypack.ExternalOutput?name=myname").include(request,response); %>
</body>
</html>
*** end ***
the error it is giving is that NoClassFoundException for com.mypack.ExternalOutput?name=myname
So, instead of treating it as URL it is treating whole URL as classname only
Is there any to overcome this ???
 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bind you name=myname to the request object before doing the dispatch statement. That way, you do not have to include it on your URL line, but it will still be accessible to your servlet from the HttpRequest object.
HTH
Brian
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic