Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: dispatch/ForwardWithQueryTarget.java


1   /*
2    * $Id: ForwardWithQueryTarget.java,v 1.1.1.1 2000/02/26 01:32:22 shawn Exp $
3    */
4   
5   /**
6    * Test FORWARD with a query string
7    *
8    * @author Arun Jamwal [arunj@eng.sun.com]
9    */
10  
11  
12  package dispatch;
13  
14  import javax.servlet.*;
15  import javax.servlet.http.*;
16  import java.io.*;
17  import java.util.*;
18  
19  public class ForwardWithQueryTarget extends HttpServlet {
20  
21      public void init() {
22        context = getServletConfig().getServletContext();
23      }
24      
25      public void doGet(HttpServletRequest req, HttpServletResponse res)
26          throws IOException
27      {
28        res.setContentType(ContentType);
29        PrintWriter pwo = res.getWriter();
30        pwo.println(TargetTag);
31  
32        Hashtable hash = new Hashtable();
33        Enumeration pNames = req.getParameterNames();
34        while (pNames.hasMoreElements()) {
35             String name = (String) pNames.nextElement();
36           hash.put(name, req.getParameter(name).trim());
37        }
38  
39        boolean firstPair = true;
40          Enumeration e = hash.keys();
41        while (e.hasMoreElements()) {
42          if (firstPair) 
43          firstPair = false;
44          else 
45          pwo.print("&");
46  
47             String name = (String) e.nextElement();
48            pwo.print(name + "=" + hash.get(name));
49          }
50      }
51  
52  
53      private ServletContext context;
54      private static final String ContentType = "text/funky";
55      private static final String TargetTag = "FORWARDWITHQUERYTARGET";
56  }
57  
58  
59