• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP to include servlet  RSS feed

 
Ken Flor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I trying to include a servlet in my jsp by using

<%@ include file="/MenuServlet"%>.


where MenuServlet has been mapped correctly in web.xml.

my jsp resides in C:\bea\user_projects\domains\ed\applications\ed\jsp

and my servlet in C:\bea\user_projects\domains\ed\applications\ed\WEB-INF\classes

I do not know how to write the relative path to be included since only relative path is valid, instead of absolute path

and I am getting this error:

weblogic.utils.ParsingException: nested TokenStreamException: antlr.TokenStreamException: Could not include /MenuServlet


Appreciate Any Help Greatly.

Thanks a million in advance!
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The include directive is used to include static local files (from the server's point of view). I think you want to use the include action instead, which is evaluated dynamically:
 
Ken Flor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

thanks for your reply. I tried but nothing happen. My jsp does not display the servlet output.

Is my path correct?

<%jsp:include file="/MenuServlet" %>
[ October 10, 2006: Message edited by: Ken Flor ]
 
Ken Flor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i realise yours is include page.

What is the difference then?

thanks
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yours is called "include directive". It is only used for static content, like text, or other JSP which will be translated once.

Mine is called "include action", and can also be used to include dynamic content like servlets or other JSP which will be translated every time the page is refreshed.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a JSP Faq entry that explains the difference between the two:
http://faq.javaranch.com/view?IncludesActionDirective
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!