<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FServlet%2FRequest</id>
		<title>Java Tutorial/Servlet/Request - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java_Tutorial%2FServlet%2FRequest"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Servlet/Request&amp;action=history"/>
		<updated>2026-04-07T11:04:00Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/Servlet/Request&amp;diff=4922&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Servlet/Request&amp;diff=4922&amp;oldid=prev"/>
				<updated>2010-06-01T05:07:00Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 05:07, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/Servlet/Request&amp;diff=4921&amp;oldid=prev</id>
		<title> в 17:44, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/Servlet/Request&amp;diff=4921&amp;oldid=prev"/>
				<updated>2010-05-31T17:44:27Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==  Get Remote Host from Servlet Request ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.*;&lt;br /&gt;
import javax.servlet.*;&lt;br /&gt;
import javax.servlet.http.*;&lt;br /&gt;
public class MyServlet extends HttpServlet {&lt;br /&gt;
  public void doGet(HttpServletRequest req, HttpServletResponse res)&lt;br /&gt;
                               throws ServletException, IOException {&lt;br /&gt;
    res.setContentType(&amp;quot;text/html&amp;quot;);&lt;br /&gt;
    PrintWriter out = res.getWriter();&lt;br /&gt;
    // Get the client&amp;quot;s hostname&lt;br /&gt;
    String remoteHost = req.getRemoteHost();&lt;br /&gt;
    out.println(&amp;quot;remoteHost:&amp;quot;+remoteHost);&lt;br /&gt;
    // See if the client is allowed&lt;br /&gt;
    if (! isHostAllowed(remoteHost)) {&lt;br /&gt;
      out.println(&amp;quot;Access &amp;lt;BLINK&amp;gt;denied&amp;lt;/BLINK&amp;gt;&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    else {&lt;br /&gt;
      out.println(&amp;quot;Access granted&amp;quot;);&lt;br /&gt;
      // Display download links, etc...&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  // Disallow hosts ending with .cu, .ir, .iq, .kp, .ly, .sy, and .sd.&lt;br /&gt;
  private boolean isHostAllowed(String host) {&lt;br /&gt;
    return (!host.endsWith(&amp;quot;.cu&amp;quot;) &amp;amp;&amp;amp;&lt;br /&gt;
            !host.endsWith(&amp;quot;.ir&amp;quot;) &amp;amp;&amp;amp;&lt;br /&gt;
            !host.endsWith(&amp;quot;.iq&amp;quot;) &amp;amp;&amp;amp;&lt;br /&gt;
            !host.endsWith(&amp;quot;.kp&amp;quot;) &amp;amp;&amp;amp;&lt;br /&gt;
            !host.endsWith(&amp;quot;.ly&amp;quot;) &amp;amp;&amp;amp;&lt;br /&gt;
            !host.endsWith(&amp;quot;.sy&amp;quot;) &amp;amp;&amp;amp;&lt;br /&gt;
            !host.endsWith(&amp;quot;.sd&amp;quot;));&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Get Remote User and display welcome message ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.*;&lt;br /&gt;
import javax.servlet.*;&lt;br /&gt;
import javax.servlet.http.*;&lt;br /&gt;
import java.util.*;&lt;br /&gt;
public class MyServlet extends HttpServlet {&lt;br /&gt;
  Hashtable accesses = new Hashtable();&lt;br /&gt;
  public void doGet(HttpServletRequest req, HttpServletResponse res)&lt;br /&gt;
                               throws ServletException, IOException {&lt;br /&gt;
    res.setContentType(&amp;quot;text/html&amp;quot;);&lt;br /&gt;
    PrintWriter out = res.getWriter();&lt;br /&gt;
    String remoteUser = req.getRemoteUser();&lt;br /&gt;
    if (remoteUser == null) {&lt;br /&gt;
      out.println(&amp;quot;Welcome!&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    else {&lt;br /&gt;
      out.println(&amp;quot;Welcome, &amp;quot; + remoteUser + &amp;quot;!&amp;quot;);&lt;br /&gt;
      Date lastAccess = (Date) accesses.get(remoteUser);&lt;br /&gt;
      if (lastAccess == null) {&lt;br /&gt;
        out.println(&amp;quot;This is your first visit!&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      else {&lt;br /&gt;
        out.println(&amp;quot;Your last visit was &amp;quot; + accesses.get(remoteUser));&lt;br /&gt;
      }&lt;br /&gt;
      if (remoteUser.equals(&amp;quot;YourFirendName&amp;quot;)) {&lt;br /&gt;
        out.println(&amp;quot;Shall we play a game?&amp;quot;);&lt;br /&gt;
      }&lt;br /&gt;
      accesses.put(remoteUser, new Date());&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Get Servlet Request Parameter ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.*;&lt;br /&gt;
import javax.servlet.*;&lt;br /&gt;
import javax.servlet.http.*;&lt;br /&gt;
import java.util.*;&lt;br /&gt;
import java.text.DateFormat;&lt;br /&gt;
public class MyServlet extends HttpServlet {&lt;br /&gt;
   &lt;br /&gt;
    public void doGet(HttpServletRequest request, HttpServletResponse response)&lt;br /&gt;
    throws ServletException, IOException {&lt;br /&gt;
  &lt;br /&gt;
    ServletOutputStream out = response.getOutputStream();&lt;br /&gt;
    String fileName = request.getParameter(&amp;quot;file&amp;quot;);&lt;br /&gt;
      &lt;br /&gt;
        out.println(&amp;quot;&amp;lt;html&amp;gt;&amp;quot;);&lt;br /&gt;
        out.println(&amp;quot;&amp;lt;head&amp;gt;&amp;quot;);&lt;br /&gt;
        out.println(&amp;quot;&amp;lt;title&amp;gt;Welcome&amp;lt;/title&amp;gt;&amp;quot;);  &lt;br /&gt;
        out.println(&amp;quot;&amp;lt;/head&amp;gt;&amp;quot;);&lt;br /&gt;
        out.println(&amp;quot;&amp;lt;body&amp;gt;&amp;quot;);&lt;br /&gt;
        out.println(&amp;quot;&amp;lt;h2&amp;gt;The File&amp;lt;/h2&amp;gt;&amp;quot;);&lt;br /&gt;
        out.println(fileName);&lt;br /&gt;
        out.println(&amp;quot;&amp;lt;/body&amp;gt;&amp;quot;);&lt;br /&gt;
        out.println(&amp;quot;&amp;lt;/html&amp;gt;&amp;quot;);&lt;br /&gt;
        out.close();&lt;br /&gt;
    &lt;br /&gt;
    } //end doGet&lt;br /&gt;
   &lt;br /&gt;
    public void doPost(HttpServletRequest request, HttpServletResponse response)&lt;br /&gt;
    throws ServletException, IOException {&lt;br /&gt;
        &lt;br /&gt;
        doGet(request,response);&lt;br /&gt;
    } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Get Users IP Address ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import java.io.PrintWriter;&lt;br /&gt;
import javax.servlet.ServletException;&lt;br /&gt;
import javax.servlet.http.HttpServlet;&lt;br /&gt;
import javax.servlet.http.HttpServletRequest;&lt;br /&gt;
import javax.servlet.http.HttpServletResponse;&lt;br /&gt;
public class Main extends HttpServlet {&lt;br /&gt;
  protected void service(HttpServletRequest request, HttpServletResponse response)&lt;br /&gt;
      throws ServletException, IOException {&lt;br /&gt;
    response.setContentType(&amp;quot;text/html;charset=UTF-8&amp;quot;);&lt;br /&gt;
    PrintWriter out = response.getWriter();&lt;br /&gt;
    // Print out the IP address of the caller&lt;br /&gt;
    out.println(request.getRemoteAddr());&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Print Request Headers for a Servlet ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import java.io.*;&lt;br /&gt;
import javax.servlet.*;&lt;br /&gt;
import javax.servlet.http.*;&lt;br /&gt;
import java.util.*;&lt;br /&gt;
public class MyServlet extends HttpServlet {&lt;br /&gt;
  public void doGet(HttpServletRequest req, HttpServletResponse res)&lt;br /&gt;
                               throws ServletException, IOException {&lt;br /&gt;
    res.setContentType(&amp;quot;text/plain&amp;quot;);&lt;br /&gt;
    PrintWriter out = res.getWriter();&lt;br /&gt;
    out.println(&amp;quot;Request Headers:&amp;quot;);&lt;br /&gt;
    out.println();&lt;br /&gt;
    Enumeration names = req.getHeaderNames();&lt;br /&gt;
    while (names.hasMoreElements()) {&lt;br /&gt;
      String name = (String) names.nextElement();&lt;br /&gt;
      Enumeration values = req.getHeaders(name);  // support multiple values&lt;br /&gt;
      if (values != null) {&lt;br /&gt;
        while (values.hasMoreElements()) {&lt;br /&gt;
          String value = (String) values.nextElement();&lt;br /&gt;
          out.println(name + &amp;quot;: &amp;quot; + value);&lt;br /&gt;
        }&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Request parsing and encoding utility methods ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * Licensed to the Apache Software Foundation (ASF) under one or more&lt;br /&gt;
 * contributor license agreements.  See the NOTICE file distributed with&lt;br /&gt;
 * this work for additional information regarding copyright ownership.&lt;br /&gt;
 * The ASF licenses this file to You under the Apache License, Version 2.0&lt;br /&gt;
 * (the &amp;quot;License&amp;quot;); you may not use this file except in compliance with&lt;br /&gt;
 * the License.  You may obtain a copy of the License at&lt;br /&gt;
 * &lt;br /&gt;
 *      http://www.apache.org/licenses/LICENSE-2.0&lt;br /&gt;
 * &lt;br /&gt;
 * Unless required by applicable law or agreed to in writing, software&lt;br /&gt;
 * distributed under the License is distributed on an &amp;quot;AS IS&amp;quot; BASIS,&lt;br /&gt;
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;br /&gt;
 * See the License for the specific language governing permissions and&lt;br /&gt;
 * limitations under the License.&lt;br /&gt;
 */&lt;br /&gt;
import java.io.UnsupportedEncodingException;&lt;br /&gt;
import java.text.SimpleDateFormat;&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import java.util.TimeZone;&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * General purpose request parsing and encoding utility methods.&lt;br /&gt;
 *&lt;br /&gt;
 * @author Craig R. McClanahan&lt;br /&gt;
 * @author Tim Tye&lt;br /&gt;
 * @version $Revision: 901 $ $Date: 2009-01-15 16:49:36 +0100 (Thu, 15 Jan 2009) $&lt;br /&gt;
 */&lt;br /&gt;
public final class RequestUtil {&lt;br /&gt;
    /**&lt;br /&gt;
     * The DateFormat to use for generating readable dates in cookies.&lt;br /&gt;
     */&lt;br /&gt;
    private static SimpleDateFormat format =&lt;br /&gt;
        new SimpleDateFormat(&amp;quot; EEEE, dd-MMM-yy kk:mm:ss zz&amp;quot;);&lt;br /&gt;
    static {&lt;br /&gt;
        format.setTimeZone(TimeZone.getTimeZone(&amp;quot;GMT&amp;quot;));&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Filter the specified message string for characters that are sensitive&lt;br /&gt;
     * in HTML.  This avoids potential attacks caused by including JavaScript&lt;br /&gt;
     * codes in the request URL that is often reported in error messages.&lt;br /&gt;
     *&lt;br /&gt;
     * @param message The message string to be filtered&lt;br /&gt;
     */&lt;br /&gt;
    public static String filter(String message) {&lt;br /&gt;
        if (message == null)&lt;br /&gt;
            return (null);&lt;br /&gt;
        char content[] = new char[message.length()];&lt;br /&gt;
        message.getChars(0, message.length(), content, 0);&lt;br /&gt;
        StringBuffer result = new StringBuffer(content.length + 50);&lt;br /&gt;
        for (int i = 0; i &amp;lt; content.length; i++) {&lt;br /&gt;
            switch (content[i]) {&lt;br /&gt;
            case &amp;quot;&amp;lt;&amp;quot;:&lt;br /&gt;
                result.append(&amp;quot;&amp;amp;lt;&amp;quot;);&lt;br /&gt;
                break;&lt;br /&gt;
            case &amp;quot;&amp;gt;&amp;quot;:&lt;br /&gt;
                result.append(&amp;quot;&amp;amp;gt;&amp;quot;);&lt;br /&gt;
                break;&lt;br /&gt;
            case &amp;quot;&amp;amp;&amp;quot;:&lt;br /&gt;
                result.append(&amp;quot;&amp;amp;amp;&amp;quot;);&lt;br /&gt;
                break;&lt;br /&gt;
            case &amp;quot;&amp;quot;&amp;quot;:&lt;br /&gt;
                result.append(&amp;quot;&amp;amp;quot;&amp;quot;);&lt;br /&gt;
                break;&lt;br /&gt;
            default:&lt;br /&gt;
                result.append(content[i]);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return (result.toString());&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Normalize a relative URI path that may have relative values (&amp;quot;/./&amp;quot;,&lt;br /&gt;
     * &amp;quot;/../&amp;quot;, and so on ) it it.  &amp;lt;strong&amp;gt;WARNING&amp;lt;/strong&amp;gt; - This method is&lt;br /&gt;
     * useful only for normalizing application-generated paths.  It does not&lt;br /&gt;
     * try to perform security checks for malicious input.&lt;br /&gt;
     *&lt;br /&gt;
     * @param path Relative path to be normalized&lt;br /&gt;
     */&lt;br /&gt;
    public static String normalize(String path) {&lt;br /&gt;
        return normalize(path, true);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Normalize a relative URI path that may have relative values (&amp;quot;/./&amp;quot;,&lt;br /&gt;
     * &amp;quot;/../&amp;quot;, and so on ) it it.  &amp;lt;strong&amp;gt;WARNING&amp;lt;/strong&amp;gt; - This method is&lt;br /&gt;
     * useful only for normalizing application-generated paths.  It does not&lt;br /&gt;
     * try to perform security checks for malicious input.&lt;br /&gt;
     *&lt;br /&gt;
     * @param path Relative path to be normalized&lt;br /&gt;
     * @param replaceBackSlash Should &amp;quot;\\&amp;quot; be replaced with &amp;quot;/&amp;quot;&lt;br /&gt;
     */&lt;br /&gt;
    public static String normalize(String path, boolean replaceBackSlash) {&lt;br /&gt;
        if (path == null)&lt;br /&gt;
            return null;&lt;br /&gt;
        // Create a place for the normalized path&lt;br /&gt;
        String normalized = path;&lt;br /&gt;
        if (replaceBackSlash &amp;amp;&amp;amp; normalized.indexOf(&amp;quot;\\&amp;quot;) &amp;gt;= 0)&lt;br /&gt;
            normalized = normalized.replace(&amp;quot;\\&amp;quot;, &amp;quot;/&amp;quot;);&lt;br /&gt;
        if (normalized.equals(&amp;quot;/.&amp;quot;))&lt;br /&gt;
            return &amp;quot;/&amp;quot;;&lt;br /&gt;
        // Add a leading &amp;quot;/&amp;quot; if necessary&lt;br /&gt;
        if (!normalized.startsWith(&amp;quot;/&amp;quot;))&lt;br /&gt;
            normalized = &amp;quot;/&amp;quot; + normalized;&lt;br /&gt;
        // Resolve occurrences of &amp;quot;//&amp;quot; in the normalized path&lt;br /&gt;
        while (true) {&lt;br /&gt;
            int index = normalized.indexOf(&amp;quot;//&amp;quot;);&lt;br /&gt;
            if (index &amp;lt; 0)&lt;br /&gt;
                break;&lt;br /&gt;
            normalized = normalized.substring(0, index) +&lt;br /&gt;
                normalized.substring(index + 1);&lt;br /&gt;
        }&lt;br /&gt;
        // Resolve occurrences of &amp;quot;/./&amp;quot; in the normalized path&lt;br /&gt;
        while (true) {&lt;br /&gt;
            int index = normalized.indexOf(&amp;quot;/./&amp;quot;);&lt;br /&gt;
            if (index &amp;lt; 0)&lt;br /&gt;
                break;&lt;br /&gt;
            normalized = normalized.substring(0, index) +&lt;br /&gt;
                normalized.substring(index + 2);&lt;br /&gt;
        }&lt;br /&gt;
        // Resolve occurrences of &amp;quot;/../&amp;quot; in the normalized path&lt;br /&gt;
        while (true) {&lt;br /&gt;
            int index = normalized.indexOf(&amp;quot;/../&amp;quot;);&lt;br /&gt;
            if (index &amp;lt; 0)&lt;br /&gt;
                break;&lt;br /&gt;
            if (index == 0)&lt;br /&gt;
                return (null);  // Trying to go outside our context&lt;br /&gt;
            int index2 = normalized.lastIndexOf(&amp;quot;/&amp;quot;, index - 1);&lt;br /&gt;
            normalized = normalized.substring(0, index2) +&lt;br /&gt;
                normalized.substring(index + 3);&lt;br /&gt;
        }&lt;br /&gt;
        // Return the normalized path that we have completed&lt;br /&gt;
        return (normalized);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Append request parameters from the specified String to the specified&lt;br /&gt;
     * Map.  It is presumed that the specified Map is not accessed from any&lt;br /&gt;
     * other thread, so no synchronization is performed.&lt;br /&gt;
     * &amp;lt;p&amp;gt;&lt;br /&gt;
     * &amp;lt;strong&amp;gt;IMPLEMENTATION NOTE&amp;lt;/strong&amp;gt;:  URL decoding is performed&lt;br /&gt;
     * individually on the parsed name and value elements, rather than on&lt;br /&gt;
     * the entire query string ahead of time, to properly deal with the case&lt;br /&gt;
     * where the name or value includes an encoded &amp;quot;=&amp;quot; or &amp;quot;&amp;amp;&amp;quot; character&lt;br /&gt;
     * that would otherwise be interpreted as a delimiter.&lt;br /&gt;
     *&lt;br /&gt;
     * @param map Map that accumulates the resulting parameters&lt;br /&gt;
     * @param data Input string containing request parameters&lt;br /&gt;
     *&lt;br /&gt;
     * @exception IllegalArgumentException if the data is malformed&lt;br /&gt;
     */&lt;br /&gt;
    public static void parseParameters(Map map, String data, String encoding)&lt;br /&gt;
        throws UnsupportedEncodingException {&lt;br /&gt;
        if ((data != null) &amp;amp;&amp;amp; (data.length() &amp;gt; 0)) {&lt;br /&gt;
            // use the specified encoding to extract bytes out of the&lt;br /&gt;
            // given string so that the encoding is not lost. If an&lt;br /&gt;
            // encoding is not specified, let it use platform default&lt;br /&gt;
            byte[] bytes = null;&lt;br /&gt;
            try {&lt;br /&gt;
                if (encoding == null) {&lt;br /&gt;
                    bytes = data.getBytes();&lt;br /&gt;
                } else {&lt;br /&gt;
                    bytes = data.getBytes(encoding);&lt;br /&gt;
                }&lt;br /&gt;
            } catch (UnsupportedEncodingException uee) {&lt;br /&gt;
            }&lt;br /&gt;
            parseParameters(map, bytes, encoding);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Decode and return the specified URL-encoded String.&lt;br /&gt;
     * When the byte array is converted to a string, the system default&lt;br /&gt;
     * character encoding is used...  This may be different than some other&lt;br /&gt;
     * servers. It is assumed the string is not a query string.&lt;br /&gt;
     *&lt;br /&gt;
     * @param str The url-encoded string&lt;br /&gt;
     *&lt;br /&gt;
     * @exception IllegalArgumentException if a &amp;quot;%&amp;quot; character is not followed&lt;br /&gt;
     * by a valid 2-digit hexadecimal number&lt;br /&gt;
     */&lt;br /&gt;
    public static String URLDecode(String str) {&lt;br /&gt;
        return URLDecode(str, null);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Decode and return the specified URL-encoded String. It is assumed the&lt;br /&gt;
     * string is not a query string.&lt;br /&gt;
     *&lt;br /&gt;
     * @param str The url-encoded string&lt;br /&gt;
     * @param enc The encoding to use; if null, the default encoding is used&lt;br /&gt;
     * @exception IllegalArgumentException if a &amp;quot;%&amp;quot; character is not followed&lt;br /&gt;
     * by a valid 2-digit hexadecimal number&lt;br /&gt;
     */&lt;br /&gt;
    public static String URLDecode(String str, String enc) {&lt;br /&gt;
        return URLDecode(str, enc, false);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Decode and return the specified URL-encoded String.&lt;br /&gt;
     *&lt;br /&gt;
     * @param str The url-encoded string&lt;br /&gt;
     * @param enc The encoding to use; if null, the default encoding is used&lt;br /&gt;
     * @param isQuery Is this a query string being processed&lt;br /&gt;
     * @exception IllegalArgumentException if a &amp;quot;%&amp;quot; character is not followed&lt;br /&gt;
     * by a valid 2-digit hexadecimal number&lt;br /&gt;
     */&lt;br /&gt;
    public static String URLDecode(String str, String enc, boolean isQuery) {&lt;br /&gt;
        if (str == null)&lt;br /&gt;
            return (null);&lt;br /&gt;
        // use the specified encoding to extract bytes out of the&lt;br /&gt;
        // given string so that the encoding is not lost. If an&lt;br /&gt;
        // encoding is not specified, let it use platform default&lt;br /&gt;
        byte[] bytes = null;&lt;br /&gt;
        try {&lt;br /&gt;
            if (enc == null) {&lt;br /&gt;
                bytes = str.getBytes();&lt;br /&gt;
            } else {&lt;br /&gt;
                bytes = str.getBytes(enc);&lt;br /&gt;
            }&lt;br /&gt;
        } catch (UnsupportedEncodingException uee) {}&lt;br /&gt;
        return URLDecode(bytes, enc, isQuery);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Decode and return the specified URL-encoded byte array.&lt;br /&gt;
     *&lt;br /&gt;
     * @param bytes The url-encoded byte array&lt;br /&gt;
     * @exception IllegalArgumentException if a &amp;quot;%&amp;quot; character is not followed&lt;br /&gt;
     * by a valid 2-digit hexadecimal number&lt;br /&gt;
     */&lt;br /&gt;
    public static String URLDecode(byte[] bytes) {&lt;br /&gt;
        return URLDecode(bytes, null);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Decode and return the specified URL-encoded byte array.&lt;br /&gt;
     *&lt;br /&gt;
     * @param bytes The url-encoded byte array&lt;br /&gt;
     * @param enc The encoding to use; if null, the default encoding is used&lt;br /&gt;
     * @exception IllegalArgumentException if a &amp;quot;%&amp;quot; character is not followed&lt;br /&gt;
     * by a valid 2-digit hexadecimal number&lt;br /&gt;
     */&lt;br /&gt;
    public static String URLDecode(byte[] bytes, String enc) {&lt;br /&gt;
        return URLDecode(bytes, null, false);&lt;br /&gt;
    }&lt;br /&gt;
    /**&lt;br /&gt;
     * Decode and return the specified URL-encoded byte array.&lt;br /&gt;
     *&lt;br /&gt;
     * @param bytes The url-encoded byte array&lt;br /&gt;
     * @param enc The encoding to use; if null, the default encoding is used&lt;br /&gt;
     * @param isQuery Is this a query string being processed&lt;br /&gt;
     * @exception IllegalArgumentException if a &amp;quot;%&amp;quot; character is not followed&lt;br /&gt;
     * by a valid 2-digit hexadecimal number&lt;br /&gt;
     */&lt;br /&gt;
    public static String URLDecode(byte[] bytes, String enc, boolean isQuery) {&lt;br /&gt;
        if (bytes == null)&lt;br /&gt;
            return (null);&lt;br /&gt;
        int len = bytes.length;&lt;br /&gt;
        int ix = 0;&lt;br /&gt;
        int ox = 0;&lt;br /&gt;
        while (ix &amp;lt; len) {&lt;br /&gt;
            byte b = bytes[ix++];     // Get byte to test&lt;br /&gt;
            if (b == &amp;quot;+&amp;quot; &amp;amp;&amp;amp; isQuery) {&lt;br /&gt;
                b = (byte)&amp;quot; &amp;quot;;&lt;br /&gt;
            } else if (b == &amp;quot;%&amp;quot;) {&lt;br /&gt;
                b = (byte) ((convertHexDigit(bytes[ix++]) &amp;lt;&amp;lt; 4)&lt;br /&gt;
                            + convertHexDigit(bytes[ix++]));&lt;br /&gt;
            }&lt;br /&gt;
            bytes[ox++] = b;&lt;br /&gt;
        }&lt;br /&gt;
        if (enc != null) {&lt;br /&gt;
            try {&lt;br /&gt;
                return new String(bytes, 0, ox, enc);&lt;br /&gt;
            } catch (Exception e) {&lt;br /&gt;
                e.printStackTrace();&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        return new String(bytes, 0, ox);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Convert a byte character value to hexidecimal digit value.&lt;br /&gt;
     *&lt;br /&gt;
     * @param b the character value byte&lt;br /&gt;
     */&lt;br /&gt;
    private static byte convertHexDigit( byte b ) {&lt;br /&gt;
        if ((b &amp;gt;= &amp;quot;0&amp;quot;) &amp;amp;&amp;amp; (b &amp;lt;= &amp;quot;9&amp;quot;)) return (byte)(b - &amp;quot;0&amp;quot;);&lt;br /&gt;
        if ((b &amp;gt;= &amp;quot;a&amp;quot;) &amp;amp;&amp;amp; (b &amp;lt;= &amp;quot;f&amp;quot;)) return (byte)(b - &amp;quot;a&amp;quot; + 10);&lt;br /&gt;
        if ((b &amp;gt;= &amp;quot;A&amp;quot;) &amp;amp;&amp;amp; (b &amp;lt;= &amp;quot;F&amp;quot;)) return (byte)(b - &amp;quot;A&amp;quot; + 10);&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Put name and value pair in map.  When name already exist, add value&lt;br /&gt;
     * to array of values.&lt;br /&gt;
     *&lt;br /&gt;
     * @param map The map to populate&lt;br /&gt;
     * @param name The parameter name&lt;br /&gt;
     * @param value The parameter value&lt;br /&gt;
     */&lt;br /&gt;
    private static void putMapEntry( Map map, String name, String value) {&lt;br /&gt;
        String[] newValues = null;&lt;br /&gt;
        String[] oldValues = (String[]) map.get(name);&lt;br /&gt;
        if (oldValues == null) {&lt;br /&gt;
            newValues = new String[1];&lt;br /&gt;
            newValues[0] = value;&lt;br /&gt;
        } else {&lt;br /&gt;
            newValues = new String[oldValues.length + 1];&lt;br /&gt;
            System.arraycopy(oldValues, 0, newValues, 0, oldValues.length);&lt;br /&gt;
            newValues[oldValues.length] = value;&lt;br /&gt;
        }&lt;br /&gt;
        map.put(name, newValues);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    /**&lt;br /&gt;
     * Append request parameters from the specified String to the specified&lt;br /&gt;
     * Map.  It is presumed that the specified Map is not accessed from any&lt;br /&gt;
     * other thread, so no synchronization is performed.&lt;br /&gt;
     * &amp;lt;p&amp;gt;&lt;br /&gt;
     * &amp;lt;strong&amp;gt;IMPLEMENTATION NOTE&amp;lt;/strong&amp;gt;:  URL decoding is performed&lt;br /&gt;
     * individually on the parsed name and value elements, rather than on&lt;br /&gt;
     * the entire query string ahead of time, to properly deal with the case&lt;br /&gt;
     * where the name or value includes an encoded &amp;quot;=&amp;quot; or &amp;quot;&amp;amp;&amp;quot; character&lt;br /&gt;
     * that would otherwise be interpreted as a delimiter.&lt;br /&gt;
     *&lt;br /&gt;
     * NOTE: byte array data is modified by this method.  Caller beware.&lt;br /&gt;
     *&lt;br /&gt;
     * @param map Map that accumulates the resulting parameters&lt;br /&gt;
     * @param data Input string containing request parameters&lt;br /&gt;
     * @param encoding Encoding to use for converting hex&lt;br /&gt;
     *&lt;br /&gt;
     * @exception UnsupportedEncodingException if the data is malformed&lt;br /&gt;
     */&lt;br /&gt;
    public static void parseParameters(Map map, byte[] data, String encoding)&lt;br /&gt;
        throws UnsupportedEncodingException {&lt;br /&gt;
        if (data != null &amp;amp;&amp;amp; data.length &amp;gt; 0) {&lt;br /&gt;
            int    ix = 0;&lt;br /&gt;
            int    ox = 0;&lt;br /&gt;
            String key = null;&lt;br /&gt;
            String value = null;&lt;br /&gt;
            while (ix &amp;lt; data.length) {&lt;br /&gt;
                byte c = data[ix++];&lt;br /&gt;
                switch ((char) c) {&lt;br /&gt;
                case &amp;quot;&amp;amp;&amp;quot;:&lt;br /&gt;
                    value = new String(data, 0, ox, encoding);&lt;br /&gt;
                    if (key != null) {&lt;br /&gt;
                        putMapEntry(map, key, value);&lt;br /&gt;
                        key = null;&lt;br /&gt;
                    }&lt;br /&gt;
                    ox = 0;&lt;br /&gt;
                    break;&lt;br /&gt;
                case &amp;quot;=&amp;quot;:&lt;br /&gt;
                    if (key == null) {&lt;br /&gt;
                        key = new String(data, 0, ox, encoding);&lt;br /&gt;
                        ox = 0;&lt;br /&gt;
                    } else {&lt;br /&gt;
                        data[ox++] = c;&lt;br /&gt;
                    }                   &lt;br /&gt;
                    break;  &lt;br /&gt;
                case &amp;quot;+&amp;quot;:&lt;br /&gt;
                    data[ox++] = (byte)&amp;quot; &amp;quot;;&lt;br /&gt;
                    break;&lt;br /&gt;
                case &amp;quot;%&amp;quot;:&lt;br /&gt;
                    data[ox++] = (byte)((convertHexDigit(data[ix++]) &amp;lt;&amp;lt; 4)&lt;br /&gt;
                                    + convertHexDigit(data[ix++]));&lt;br /&gt;
                    break;&lt;br /&gt;
                default:&lt;br /&gt;
                    data[ox++] = c;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            //The last value does not end in &amp;quot;&amp;amp;&amp;quot;.  So save it now.&lt;br /&gt;
            if (key != null) {&lt;br /&gt;
                value = new String(data, 0, ox, encoding);&lt;br /&gt;
                putMapEntry(map, key, value);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>