aspose file tools*
The moose likes Servlets and the fly likes Including resource using Include method using RequestDispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Including resource using Include method using RequestDispatcher" Watch "Including resource using Include method using RequestDispatcher" New topic
Author

Including resource using Include method using RequestDispatcher

Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Hi I'm using include method using RequestDispatcher.
I have two servlet for that.

IncludeServlet.java
===================


Copyright.java
===============


When i tried to run this code i got following output

output
======
Welcome to Our Universe
Imagine the rest of the page here

The requested resource (/Ch06/dispatcher) is not available

=========================

what could be the reason og getting "The requested resource (/Ch06/dispatcher) is not available ".
How to resolve it.

Please Help.

Thanks in Advance.
Mohamed Inayath
Ranch Hand

Joined: Nov 22, 2004
Posts: 124
Have you got the Servlet mapping entries in web.xml for the Copyright Servlet.

Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Hi Mohamed,

Below is web.xml.


web.xml
======

<servlet>
<servlet-name>IncludeServlet</servlet-name>
<servlet-class>src.com.IncludeServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>Copyright</servlet-name>
<servlet-class>src.com.Copyright</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>IncludeServlet</servlet-name>
<url-pattern>/includeservlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Copyright</servlet-name>
<url-pattern>/copyright</url-pattern>
</servlet-mapping>


Thanks for reply.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874




Here request.getRequestDispatcher("/dispatcher") should contain Copyright url pattern from web.xml
Jay Shukla
Ranch Hand

Joined: Jun 08, 2008
Posts: 214
Hi Balu,

Thanks a lot. I have made changes and now its working.

I want to know one thing.

"If there is a servlet included into another servletn and if there is an entry of invokerServlet in the web.xml (of tomcat directory /conf folder) then can you ignore making an entry of <servlet-mapping> in web.xml for included servet."

Thanks in Advance.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Jay,

I guess No. all servlets are to be declared inside the web.xml to be accessed at any way (directly or indirectly).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Including resource using Include method using RequestDispatcher
 
Similar Threads
Using getNamedDispatcher() to forward a request
Servlet HelloWorld problem
what's wrong with this?
Not Getting proper output for Servlet Application
Servlet not being called