Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## example.servlet.basic
Class URLServlet

    example.servlet.basic.URLServlet

public class URLServlet

Shows how to extract the URL components.

     http://localhost:8080/tutorial/servlet/example.URLServlet/foo?a=b

getScheme | http
getServerName | localhost
getServerPort | 8080
getContextPath | /tutorial
getServletPath | /servlet/example.URLServlet
getPathInfo | /foo
getQueryString | a=b

The contextPath, servletPath, and pathInfo are related to how URLs map to servlets.

Each host is composed of one or more web-applications, specified by a URI prefix, the contextPath. This tutorial, for example, is in a web-app named /tutorial. A web-app is a miniature virtual host. The web-apps are protected from each other and the classes are entirely distinct. Because web-apps are often renamed, the servlets should be written not to care what the contextPath is. For example, any absolute URL needs to add the contextPath. If the servlet wanted a link to /tutorial/foo.jsp, it would use: ``

     out.println("<a href=\"" + request.getContextPath() + "/foo.jsp>");

servletPath is the URL that maps directly to the servlet. Examples would be /servlet/example.URLServlet or /test/foo.jsp. (Since *.jsp files are really servlets.)

pathInfo is the part of the URL after the servlet path. Servlets will often use the pathInfo as some sort of database key.

queryString is the query part of the URL. Normally, servlets use the getParameter call instead of parting the query string directly.

Constructor Summary
`URLServlet()`

Method Summary
`void` | `doGet(example.servlet.basic.HttpServletRequest request, example.servlet.basic.HttpServletResponse response)` Handles GET requests.

Constructor Detail

### URLServlet

    public URLServlet()

Method Detail

### doGet

    public void doGet(example.servlet.basic.HttpServletRequest request,
                      example.servlet.basic.HttpServletResponse response)
               throws java.io.IOException,
                      example.servlet.basic.ServletException

  Handles GET requests. Resin will call the doGet method when the browser sends a GET request.
  Parameters:
    `request` - the request object contains the data from the browser's request.
    `response` - the response object contains methods to send data back to the browser.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD