• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to use the include() command in JSP

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • 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 ???
 
Brian Nice
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic