Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaBeat Sample Question

 
deepa raj
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given the deployment descriptor for a Web Application is



What will be the output of the following Servlet?



 
sudhakar karnati
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer is 1. The Servlet will output 'javabeat null' in the Server Console.

Thanks & Regards,
Sudhakar Karnati
 
Ramesh Ponnada
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
init-param tag is part of <servlet> not <servlet-mapping>

So, above code will print 2 nulls.
 
Jan Sterk
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Savyatha Reddy
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so, is the above code gives an output of "javabeat null" OR "null null"
 
Prasad Tamirisa
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • 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
 
Srividhya Kiran
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • 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
  • 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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic