• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

JavaBeat Sample Question

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Given the deployment descriptor for a Web Application is



What will be the output of the following Servlet?



 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answer is 1. The Servlet will output 'javabeat null' in the Server Console.

Thanks & Regards,
Sudhakar Karnati
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
init-param tag is part of <servlet> not <servlet-mapping>

So, above code will print 2 nulls.
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ramesh Ponnada:
init-param tag is part of <servlet> not <servlet-mapping>

So, above code will print 2 nulls.



Good point!!
 
sudhakar karnati
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Answer is 1. The Servlet will output 'javabeat null' in the Server Console.



I ran the above example in Netbeans.and its extra features made me this mistake.

Thanks
Sudhakar
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so, is the above code gives an output of "javabeat null" OR "null null"
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

so, is the above code gives an output of "javabeat null" OR "null null"



Its very clear. The Answer is null null
 
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

I think we get a compile time error by declaring <init-param> as a subelement of <servlet-mapping>. I am using eclipse and it gives me a error if I give <init-param> under <servlet-mapping> element.

Srividhya
 
Ramesh Ponnada
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IDEs like eclipse, netbeans can have schema validation enabled.
Because init-param is not a part of servlet-mapping it schema validation fails and eclipse reports it as a error in the problems view.
(one can disable the validations in the eclipse preferences)


Also, if you have XML-Validation turned on in the container(I am taking about Tomcat, I don't know how to do it in others) web application won't start/load.
[ August 11, 2008: Message edited by: Ramesh Ponnada ]
reply
    Bookmark Topic Watch Topic
  • New Topic