source: nutchez-0.1/tomcat/webapps/examples/servlets/reqparams.html @ 222

Last change on this file since 222 was 66, checked in by waue, 16 years ago

NutchEz - an easy way to nutch

File size: 4.5 KB
Line 
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<html>
18<head>
19<title>Untitled Document</title>
20<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
21</head>
22
23<body bgcolor="#FFFFFF">
24<p><font color="#0000FF"><a href="servlet/RequestParamExample"><img src="images/execute.gif" align="right" border="0"></a><a href="index.html"><img src="images/return.gif" width="24" height="24" align="right" border="0"></a></font></p>
25<h3>Source Code for Request Parameter Example<font color="#0000FF"><br>
26  </font> </h3>
27<font color="#0000FF"></font> 
28<pre><font color="#0000FF">import</font> java.io.*;
29<font color="#0000FF">import</font> java.util.*;
30<font color="#0000FF">import</font> javax.servlet.*;
31<font color="#0000FF">import</font> javax.servlet.http.*;
32
33<font color="#0000FF">public class</font> RequestParamExample <font color="#0000FF">extends</font> HttpServlet {
34
35    <font color="#0000FF">public void</font> doGet(HttpServletRequest request, HttpServletResponse response)
36    <font color="#0000FF">throws</font> IOException, ServletException
37    {
38        response.setContentType(&quot;<font color="#009900">text/html</font>&quot;);
39        PrintWriter out = response.getWriter();
40        out.println(&quot;<font color="#009900">&lt;html&gt;</font>&quot;);
41        out.println(&quot;<font color="#009900">&lt;head&gt;</font>&quot;);
42        out.println(&quot;<font color="#009900">&lt;title&gt;Request Parameters Example&lt;/title&gt;</font>&quot;);
43        out.println(&quot;<font color="#009900">&lt;/head&gt;</font>&quot;);
44        out.println(&quot;<font color="#009900">&lt;body&gt;</font>&quot;);
45        out.println(&quot;<font color="#009900">&lt;h3&gt;Request Parameters Example&lt;/h3&gt;</font>&quot;);
46        out.println(&quot;<font color="#009900">Parameters in this request:&lt;br&gt;</font>&quot;);
47        if (firstName != null || lastName != null) {
48            out.println(&quot;<font color="#009900">First Name:</font>&quot;);
49            out.println(&quot;<font color="#009900"> = </font>&quot; + HTMLFilter.filter(firstName) + &quot;<font color="#009900">&lt;br&gt;</font>&quot;);
50            out.println(&quot;<font color="#009900">Last Name:</font>&quot;);
51            out.println(&quot;<font color="#009900"> = </font>&quot; + HTMLFilter.filter(lastName));
52        } else {
53            out.println(&quot;<font color="#009900">No Parameters, Please enter some</font>&quot;);
54        }
55        out.println(&quot;<font color="#009900">&lt;P&gt;</font>&quot;);
56        out.print(&quot;<font color="#009900">&lt;form action=\"</font>&quot;);
57        out.print(&quot;<font color="#009900">RequestParamExample\" </font>&quot;);
58        out.println(&quot;<font color="#009900">method=POST&gt;</font>&quot;);
59        out.println(&quot;<font color="#009900">First Name:</font>&quot;);
60        out.println(&quot;<font color="#009900">&lt;input type=text size=20 name=firstname&gt;</font>&quot;);
61        out.println(&quot;<font color="#009900">&lt;br&gt;</font>&quot;);
62        out.println(&quot;<font color="#009900">Last Name:</font>&quot;);
63        out.println(&quot;<font color="#009900">&lt;input type=text size=20 name=lastname&gt;</font>&quot;);
64        out.println(&quot;<font color="#009900">&lt;br&gt;</font>&quot;);
65        out.println(&quot;<font color="#009900">&lt;input type=submit&gt;</font>&quot;);
66        out.println(&quot;<font color="#009900">&lt;/form&gt;</font>&quot;);
67        out.println(&quot;<font color="#009900">&lt;/body&gt;</font>&quot;);
68        out.println(&quot;<font color="#009900">&lt;/html&gt;</font>&quot;);
69    }
70
71    <font color="#0000FF">public void</font> doPost(HttpServletRequest request, HttpServletResponse res)
72    <font color="#0000FF">throws</font> IOException, ServletException
73    {
74        doGet(request, response);
75    }
76}</pre>
77</body>
78</html>
Note: See TracBrowser for help on using the repository browser.