• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using include directive and action tag in one page

 
Ravi Hyd
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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?
 
Roshini Sridharan
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • 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
 
Zaheer Nanji
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!