• 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

include directive doubt?

 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

Is it true that I can do <%@ include...anywhere in my jsp?? I tried doing this where I have a jsp ad I'm doing two includes in it and in the first include which I call start.jsp, I'm opening Hibernate transaction and I include this at the top of the page and in the end.jsp, I'm closing the hibernate transaction. Now when I include the end.jsp at the end of the page, I'm actually able to run index.jsp (the one which includes both start,jsp and end.jsp). But when I do the include for end.jsp somewhere else, I'm getting 500 error. One reason I can say is that I have some thing related to database happening in my index.jsp but before end.jsp (where I close the connection and so on).

My question here is what exactly happens when we include?? Can we do the include in any place or is it place sensitive?
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,

Using include directive we can include only static content. At the time of page translation time the include directive content will be pasted in original jsp.

It�s won't do any dynamic processing of request. It�s not a pace sensitive. We can use include directive in any place of your jsp.
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

It is place sensitive....I tried testing it and when not in the correct place, it throws errors....
 
Joe San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,

I'm not talking about <%@ Page...., I'm talking about <%@ include....please note!
 
PRavi kumar
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Jothi,

Your right
Include directive is place sensitive. it's just copy and paste the content wherever you included.
 
PRavi kumar
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Jothi,

Your right
Include directive is place sensitive. it's just copy and paste the content wherever you included.
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The include directive is not, in nature, position dependent. It is in fact used to place partial content in a page wherever required.

But you must note that the partial content must be properly justified, i.e. You must know what comes before the directive and what comes after and based on that you should consider the positioning.

However if you do include some elements in the included page which when translated result in improper Servlet format then it is but obvious that will result in errors.

Try with plain HTML and then include this HTML page in a JSP page with the include directive. It wont matter then where it is placed!
reply
    Bookmark Topic Watch Topic
  • New Topic