Normalize Post Data : HTML Output « Servlets « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. EJB3
14. Email
15. Event
16. File Input Output
17. Game
18. Generics
19. GWT
20. Hibernate
21. I18N
22. J2EE
23. J2ME
24. JDK 6
25. JNDI LDAP
26. JPA
27. JSP
28. JSTL
29. Language Basics
30. Network Protocol
31. PDF RTF
32. Reflection
33. Regular Expressions
34. Scripting
35. Security
36. Servlets
37. Spring
38. Swing Components
39. Swing JFC
40. SWT JFace Eclipse
41. Threads
42. Tiny Application
43. Velocity
44. Web Services SOA
45. XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » Servlets » HTML OutputScreenshots 
Normalize Post Data
    
/*
    JSPWiki - a JSP-based WikiWiki clone.

    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.    
 */

import java.security.SecureRandom;
import java.util.Properties;
import java.util.Random;

public class StringUtils
{

  /**
   *  Makes sure that the POSTed data is conforms to certain rules.  These
   *  rules are:
   *  <UL>
   *  <LI>The data always ends with a newline (some browsers, such
   *      as NS4.x series, does not send a newline at the end, which makes
   *      the diffs a bit strange sometimes.
   *  <LI>The CR/LF/CRLF mess is normalized to plain CRLF.
   *  </UL>
   *
   *  The reason why we're using CRLF is that most browser already
   *  return CRLF since that is the closest thing to a HTTP standard.
   *  
   *  @param postData The data to normalize
   *  @return Normalized data
   */
  public static String normalizePostDataString postData )
  {
      StringBuffer sb = new StringBuffer();

      forint i = 0; i < postData.length(); i++ )
      {
          switchpostData.charAt(i) )
          {
            case 0x0a// LF, UNIX
              sb.append"\r\n" );
              break;

            case 0x0d// CR, either Mac or MSDOS
              sb.append"\r\n" );
              // If it's MSDOS, skip the LF so that we don't add it again.
              ifi < postData.length()-&& postData.charAt(i+1== 0x0a )
              {
                  i++;
              }
              break;

            default:
              sb.appendpostData.charAt(i) );
              break;
          }
      }

      ifsb.length() || !sb.substringsb.length()-).equals("\r\n") )
      {
          sb.append"\r\n" );
      }

      return sb.toString();
  }

}

   
    
    
    
  
Related examples in the same category
1. Servlet Output HTML Demo
2. Servlet Display Static HTML
3. Prints a conversion table of miles per gallon to kilometers per liter
4. Servlet: Print Table
5. Html utilities
6. Html Parse Servlet
7. Escape and unescape string
8. Escapes newlines, tabs, backslashes, and quotes in the specified string
9. Web Calendar
10. HTML Helper
11. Escape HTML
12. Convert HTML to text
13. Text To HTML
14. Unescape HTML
15. Java object representations of the HTML table structure
16. Entity Decoder
17. Format a color to HTML RGB color format (e.g. #FF0000 for Color.red)
18. Definitions of HTML character entities and conversions between unicode characters and HTML character entities
19. Encode special characters and do formatting for HTML output
20. HTML color names
21. Utility methods for dealing with HTML
22. Filter the specified message string for characters that are sensitive in HTML
23. A collection of all character entites defined in the HTML4 standard.
24. Decode an HTML color string like '#F567BA;' into a Color
25. Get HTML Color String from Java Color object
26. HTML Decoder
27. HTML Parser
28. HTML color and Java Color
29. HTML form Utilites
30. Html Dimensions
31. break Lines with HTML
32. insert HTML block dynamically
33. Convert an integer to an HTML RGB value
34. Convert to HTML string
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.