• 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

jsp:include question

 
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 836
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"?
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it gave me answer D

Thanks
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
permaculture is giving a gift to your future self. After reading this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic