Java Servlets

Total Post:113

Points:791
Java  Javac 
 167  View(s)
Ratings:
Rate this:

What are Java Servlets ?

  1. Post:140

    Points:984
    Re: Java Servlets

    Java Servlets :

    A programs that run on a Web and Application server is callled Java servelts which is act as a middle layer between a request coming from a Web browser or other HTTP client and Database. we can directly collect input from users through web page forms by using servlet 

    - Common Gateway Interface (CGI). 

    - Performance is significantly better. 

    - Servlets execute within Web server space. 

    - Its security test is good and its having independent platform. 

    import java.io.*; 
    import javax.servlet.*;
    import javax.servlet.http.*;
    // Extend HttpServlet class public class HelloWorld extends HttpServlet {
       private String message;
       public void init() throws ServletException {
          // Do required initialization
          message = "Mindstick";
       }
       public void doGet(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
          // Set response content type
          response.setContentType("text/html");
          // Actual logic goes here. PrintWriter out = response.getWriter();
          out.println("<h1>" + message + "</h1>");
       } public void destroy() {
          // do nothing.
       }
    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!