Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:include question

 
Sherif Shehab
Ranch Hand
Posts: 485
Android Eclipse IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Michael Ku
Ranch Hand
Posts: 510
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 485
Android Eclipse IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 836
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"?
 
Sherif Shehab
Ranch Hand
Posts: 485
Android Eclipse IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 510
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 485
Android Eclipse IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it gave me answer D

Thanks
 
naresh govindaswmay
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sherif Shehab
Ranch Hand
Posts: 485
Android Eclipse IDE Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic