aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes jsp:include  question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "jsp:include  question" Watch "jsp:include  question" New topic
Author

jsp:include question

Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 483

Consider the following contents for two JSP files:

In file companyhome.jsp:
<html><body>
Welcome to ABC Corp!
<jsp:include page="companynews.jsp" />
</body></htm>
<%@ page errorPage="simpleerrorhandler.jsp" %>
In file companynews.jsp:
<%@ page errorPage="advancederrorhandler.jsp" %>
<h3>Todays News</h3>


Select 1 correct option.
a When companyhome.jsp is requested, the output will contain "welcome..." as well as "Todays News".


b companyhome.jsp will not compile.


c companynews.jsp will not compile.


d Both the files will compile but will throw an exception at runtime.


e None of these.

Answer

Not convinced , any explanations?


Thanks,
Sherif
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
What happened when you tried it for yourself? What exactly are you not convinced of?
[ October 26, 2007: Message edited by: Michael Ku ]
Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 483

hi ,

this was the output when i tried it..
Welcome to ABC Corp!
Todays News


so i think the answer D is wrong ..!!

Thanks
Sherif
Charles Lyons
Author
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
From just looking at it, I agree with your test output... it works as you'd expect so the answer is A (I think). I can't see anything syntactically incorrect, nor anything which will raise an exception.

Of course, the horrendous HTML code is another matter entirely - should there possibly be an option for "my browser complained about badly written HTML/XML"?


Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )
Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 483

Ya i agree with you that the answer suppose to be A but when i answered it like this in the simulator it was wrong & the right answer was D !! without any clarification !! so may be it's a wrong answer..

Thanks
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
Could not tell which answer the simulator gave from your first post. I got the same answer when I ran it.
Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 483

it gave me answer D

Thanks
naresh govindaswmay
Ranch Hand

Joined: Aug 15, 2007
Posts: 90
hi,
How come it is possible for having two error page declaration in a single jsp file . if we have a two declaration of error page in the single page we will get the following error
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /Declaration.jsp(5,1) Page directive: illegal to have multiple occurrences of errorPage with different values (old: NewErrorPage.jsp, new: NewErrorPage1.jsp)
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:238)
org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:176)
org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:549)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
org.apache.jasper.compiler.Validator.validate(Validator.java:1438)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:214)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)

note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
Apache Tomcat/5.0.28


Thanks and Regards<br />Naresh govindaswamy
Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 483

In file companyhome.jsp:
<html><body>
Welcome to ABC Corp!
<jsp:include page="companynews.jsp" />
</body></htm>
<%@ page errorPage="simpleerrorhandler.jsp" %>
In file companynews.jsp:
<%@ page errorPage="advancederrorhandler.jsp" %>
<h3>Todays News</h3>

no two error directives in the same page , actually in 2 pages (check the italics font)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp:include question