Sunday, August 5, 2007

SCWCD: The Beginning

About a month ago, I got started studying for my WCD certification by reading the first two chapters of this book. I haven't had a chance to touch it since, so I just started from the beginning again and decided to talk a little about what I'm learning.

In the very beginning there are a lot of web development basics discussed. This includes an intro to HTML and HTTP, what a web server does, the basic life cycle of an HTTP request/response pair, how to go about creating a simple servlet. So, here's a quick summary:

HTTP & HTML
-- Most common HTTP requests are GET and POST
-- GET request has a limited (character) length
-- data sent with a GET is appended to the URL
-- data sent with a POST is contained inside the reques

Web Server
-- a Web Server (by itself) can only serve static pages
-- a 'helper application' is needed to serve dynamic content or save data

URL
-- By default, port 80 is used(port of the web server application)

Servlets
-- a simple servlet class extends HttpServlet and implements doGet() and doPost()
-- a Deployment Descriptor maps a servlet class to a url pattern


Simple Servlet


import javax.servlet.*;
import javax.servlet.http.*;

public class ChadServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException {
// IMPLEMENT ME
}
}



Simple Deployment Descriptor


<web-app ...>
<servlet>
<servlet-name>SimpleServlet</servlet-name>
<servlet-class>ChadServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>SimpleServlet</servlet-name>
<url-pattern>/myservlet</url-pattern>
</servlet-mapping>
</web-app>

No comments: