Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compilation Error

 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given the 2 jsp files:

In file companyhome.jsp:

<html><body>
Welcome to ABC Corp!
<%@ page errorPage="simpleerrorhandler.jsp" %>
<%@ include file="companynews.jsp" %>
</body></html>



In file companynews.jsp:

<%@ page errorPage="advancederrorhandler.jsp" %>
<h3>Todays News</h3>


The output of this is
companyhome.jsp will not compile


Source: JavaBeat.com


Can anybody tell me as to why it will not compile?

With regards,
Padma priya N.G.
 
Amol Nayak
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since its an include directive the jsp is included in included jsp that is
companyhome.jsp

<html><body>
Welcome to ABC Corp!
<%@ page errorPage="simpleerrorhandler.jsp" %>
<%@ page errorPage="advancederrorhandler.jsp" %>
<h3>Todays News</h3>
</body></html>


Now the spec says this

There shall be only one occurrence of any attribute/
value pair defined by this directive in a given translation unit, unless the values for
the duplicate attributes are identical for all occurrences. The import and pageEncoding
attributes are exempt from this rule and can appear multiple times.



In this case the errorPage attribute occurred more than once and has different value. Hence it will not compile.

If it was jsp:include standard action it will compile.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or in other way, there can be only one error page per JSP page.

Thanks,
 
Amol Nayak
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well chandra not exactly, the spac says it can have duplicate but the values must be same. In the above case duplicate errorPage attribute is not the problem but the value of both of them are different. It they were same it would have worked.
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks a lot. I shall fix into my brain.
With regards,
Padma priya N.G.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah Amol,

That is perfectly correct.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic