• 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

Enthuware query

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys, i took the enthuware JWebplus v4 test today. I had a query regarding the same. I'm posting it here and i hope i ain't violating any copyright laws.

Que:
You want the copyright information contained in <webapp root>/html/copyright.html to be added to the html content that your servlet generates. Which of the following code fragments occuring in doGet method would achieve this objective?

Select 1 correct option.
a. this.getServletContext().getRequestDispatcher("../html/copyright.html").include(request, response);
b. this.getServletContext().getRequestDispatcher("/html/copyright.html").include(request, response);
c. request.getRequestDispatcher("../html/copyright.html").include(request, response);
d. request.include("../html/copyright.html", request, response);
e. this.getServletContext().getRequestDispatcher("/html/copyright.html").forward(request, response);
f. request.getRequestDispatcher("/html/copyright.html").forward(request, response);

Ans: c
My ans: b

Their comments: 1. This is invalid because a relative path is being passed to getRequestDispatcher method of ServletContext. 2. This is valid because an absolute path is being passed to getRequestDispatcher method of ServletContext. (/html/copyright.html starts with a "/"). 3. This is valid because getRequestDispatcher() of ServletRequest interface supports absolute as well as relative paths. 4. There is no include method in request. 5 and 6. calling forward will forward the request to the given resource and so the data generated by this servlet will be lost.
 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kejal,

Even I gave the same answer as you have given and was surprised to see 2 answers popping up instead of one.

Even I am in a dilemma.

Thanks,
Javainn
 
Kejal Shah
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cool! so tat means, the exam's a crap. I had problems with other questions too.
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Enthuware is a decent simulator, very close to the real test (so everybody say). But these errors can be annoying.

You should report this to Enthuware, so they can improve the product in the next version.
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kejal Shah:
Cool! so tat means, the exam's a crap. I had problems with other questions too.



Kejal: That was a bit harsh. JWebPlus for the old exam had a very good reputation. Please post the questions at JDiscuss web site or send them to (jwebplus@enthuware.com or support@enthuware.com) and this would be fixed in the future releases.
 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the answer is b and c right?
bhumika
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bhumika Thakkar:
the answer is b and c right?
bhumika



YES.

1. ServletContext.getRequestDispatcher()
- accepts pathnames that must begin with a "/" and is interpreted as relative to the current context root

2. ServletRequest.getRequestDispatcher()
- accepts pathnames that are relative to the current servlet as well as pathnames that begin with a "/", which are interpreted as relative to the current context root.
reply
    Bookmark Topic Watch Topic
  • New Topic