• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaRanch SCWCD mock exam query

 
Vikrant Pandit
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is Question Bank ID : 51 .



What is the result of compiling the above Servlet and accessing it by typing:
"http://www.javaranch.com/servlet/com.javaranch.PostServlet"
into the address field of a browser


The following four options were given


The server will not find the Servlet due to an incorrect URL.



The code fails to compile.



The browser displays "Hello World"



An error page is returned from the Server.



IMO Option 1 is correct . What is your opinion ?
 
Abhishek Dharwadkar
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i think thats correct
 
Vikrant Pandit
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But the javaranch says that the answer given below is correct as
the servlet has not implemented doGet method

An error page is returned from the Server.
 
Karthikeyan Varadarajan
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you can access the servlet like that also.

/context-path/servlet/servletClass , if the servlet is inside the package , then /context-path/servlet/com.package.ServletClass (nothing but fully qualified class name).

so the first option is wrong.

the servlet is implements only doPost method but we are trying to access the servlet thro the URL which is nothing but doGet. so the server will return the error page.

Hope it helps
 
Rick Roberts
Ranch Hand
Posts: 59
Hibernate Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should generate an error something like:
404 File not found.

If it was never mapped in the deployment descriptor, then its just a class out there somewhere that has nothing to do with your web site.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic