© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu

Home Placements Interview Questions Java Interview Questions And Answers Java Interview Questions On Servlets ▼

Java Interview Questions On Servlets

7. What information that the ServletRequest interface allows the servlet access to?

Answer
Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by the client, and the names of the remote host that made the request and the server that received it. The input stream, ServletInputStream.Servlets use the input stream to get data from clients that use application protocols such as the HTTP POST and PUT methods.

8. What information that the ServletResponse interface gives the servlet methods for replying to the client?

Answer
It Allows the servlet to set the content length and MIME type of the reply. Provides an output stream, ServletOutputStream and a Writer through which the servlet can send the reply data.

9. If you want a servlet to take the same action for both GET and POST request, what should you do?

Answer

Simply have doGet call doPost, or vice versa.

10. What is the servlet life cycle?

Answer
Each servlet has the same life cycle:
A server loads and initializes the servlet (init())
The servlet handles zero or more client requests (service())
The server removes the servlet (destroy()) (some servers do this step only when they shut down)

11. Which code line must be set before any of the lines that use the PrintWriter?

Answer
setContentType() method must be set before transmitting the actual document.

12. How HTTP Servlet handles client requests?

Answer
An HTTP Servlet handles client requests through its service method. The service method supports standard HTTP client requests by dispatching each request to a method designed to handle that request.

Previous Next
1 2 3 4 5
SLogix Student Projects
bottom