KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > test > servlet > SampleServlet


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package com.test.servlet;
18
19 import java.io.*;
20
21 import javax.servlet.ServletConfig JavaDoc;
22 import javax.servlet.ServletException JavaDoc;
23 import javax.servlet.http.HttpServletRequest JavaDoc;
24 import javax.servlet.http.HttpServletResponse JavaDoc;
25
26 /**
27  * Servlet implementation class for Servlet: SampleServlet
28  *
29  * @web.servlet
30  * name="SampleServlet"
31  * display-name="SampleServlet"
32  *
33  * @web.servlet-mapping
34  * url-pattern="/SampleServlet"
35  *
36  */

37  public class SampleServlet extends javax.servlet.http.HttpServlet JavaDoc implements javax.servlet.Servlet JavaDoc {
38     /* (non-Java-doc)
39      * @see javax.servlet.http.HttpServlet#HttpServlet()
40      */

41     public SampleServlet() {
42         super();
43
44     }
45
46     /* (non-Java-doc)
47      * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
48      */

49     protected void doGet(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws ServletException JavaDoc, IOException {
50         // TODO Auto-generated method stub
51
doPost(request,response);
52     }
53
54     /* (non-Java-doc)
55      * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
56      */

57     protected void doPost(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws ServletException JavaDoc, IOException {
58         // TODO Auto-generated method stub
59

60         PrintWriter out = response.getWriter();
61         out.println("<html><head><title>Sample application with Servlets 2.5</title></head></html>");
62         out.println("<body>");
63         out.println("<font align=Center face=\"Garamond\"> Welcome to Servlets 2.5 samples..!!!</font>");
64         out.println("</body></html>");
65
66     }
67     
68     public void init(ServletConfig JavaDoc config)
69     {
70         System.out.println("Initializing servlet");
71     }
72     
73 }
Popular Tags