• 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

ServletContext getRequestDispatcher

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

according to the API, when getRequestDispatcher() is called on ServletContext object, absolute path must be given.. right?

I would like to know what happens if ServletContext.getRequestDispatcher() is given a relative path as the argument.
Will it give rise to IllegalStateException or NullPointerException?

are the SCWCD questions specific about the name of the exception?


 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Why don't you try to create a program to see what happens when you pass a relative path to the ServletContext.getRequestDispather method.
2) The exam is designed in such a way that you don't have to memorize all the stuff. Anything asked in the exam will be logical. So if what exception a method throws is logical, then it can be on the exam...
 
padma jyotsna
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have written some code and checked out
It gave an IllegalArgumentException.

I happen to read in some mock question that NullPointerException arises. I believe that is wrong answer.

please correct me if I am wrong.


 
Ankit Garg
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer must be wrong in the mock exam I guess...
 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Padma & Ankit,

It actually depends on the question being asked. it will throw an IllegalArgumentException if the path doesn't start with a "/" but it will throw a NullPointerException if path (the String object) is still null.

Regards,
Frits
 
What do you have in that there bucket? It wouldn't be a tiny ad by any chance ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic