• 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

Using include directive and action tag in one page

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can I have both Include directive and include action tag in a page. How the final servlet will be formed. How about the variables declared?

For ex:

in a.jsp
---------

int x=5;

<%@ include page="b.jsp" %>
<h4> value of x is </h4> <%= x %>
.....

<%jsp:include page="b.jsp" %>
<h4> value of x is </h4> <%= x %>

in b.jsp
-----------
int x=6;
....
<b> Hello</b>
....



what is the status of variable x when we we use include directive and include action tag is used. Where do we get error?
 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can I have both Include directive and include action tag in a page.

- Yes

How the final servlet will be formed. How about the variables declared?

The variable declared is of page scope, so there should be no problem using it in those pages. in b.jsp the variable x is not used.

in a.jsp

the value of x remains 5

so the output would be

Hello
<h4> value of x is </h4> 5
.....
Hello
<h4> value of x is </h4> 5



Regards
Roshini
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I dont think it will work. Since a.jsp declares a variable x
and b.jsp also declares variable x, the final servlet
that will be generated will not compile due to the @include tag.
reply
    Bookmark Topic Watch Topic
  • New Topic