aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Question Bank ID : 51      Section 1 - The Servlet Model Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Question Bank ID : 51      Section 1 - The Servlet Model " Watch "Question Bank ID : 51      Section 1 - The Servlet Model " New topic
Author

Question Bank ID : 51 Section 1 - The Servlet Model

friso jonge
Ranch Hand

Joined: Aug 06, 2002
Posts: 41
Hi all,
I have a question about the javaranch scwcd mock exam as you can see below. I think i have seen it before but now i cannot find it. What is the answer and why ?
i think it does not compile, but javaranch explains An error page is returned from the Server.

package com.javaranch;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class PostServlet extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>\n <body>\n");
out.println(" <h2>\n Hello World\n </h2>\n");
out.println(" </body>\n</html>\n");
out.flush();
out.close();
}
}
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
friso jonge
Ranch Hand

Joined: Aug 06, 2002
Posts: 41
sorry, i think i found the answer myself....
public abstract class HttpServlet
extends GenericServlet
implements java.io.Serializable
Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A subclass of HttpServlet must override at least one method, usually one of these:
also the class in question only has a post and not a get method which is requested...
again sorry
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Question Bank ID : 51 Section 1 - The Servlet Model