Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Including resource using Include method using RequestDispatcher

 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you got the Servlet mapping entries in web.xml for the Copyright Servlet.

 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Here request.getRequestDispatcher("/dispatcher") should contain Copyright url pattern from web.xml
 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jay,

I guess No. all servlets are to be declared inside the web.xml to be accessed at any way (directly or indirectly).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic