Java
  Home arrow Java arrow Page 6 - The JSP Files (part 3): Black Light An...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

The JSP Files (part 3): Black Light And White Rabbits
By: Vikram Vaswani and Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2001-03-01

    Table of Contents:
  • The JSP Files (part 3): Black Light And White Rabbits
  • Doing More With Loops
  • For-gone Conclusion
  • The Sound Of Breaking Loops
  • Paying The Piper
  • You Say Seven, I Say 7
  • A Positive Response

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!

    The JSP Files (part 3): Black Light And White Rabbits - You Say Seven, I Say 7


    (Page 6 of 7 )

    And finally, in case you've ever wanted to convert strings to numbers, the following example should tell you everything you need to know.


    <% // converting a string to a number

    // define variables String someString = "97"; int aRandomNumber = 3;

    // at this stage, someString is still treated as a string out.println(someString + " plus " + aRandomNumber + " equals " + (someString+aRandomNumber) + "<p>");

    // now convert someString to a number int someNumber = Integer.parseInt(someString);

    // at this stage, someString has been converted to a number, stored in someNumber out.println(someNumber + " plus " + aRandomNumber + " equals " + (someNumber+aRandomNumber));

    %>


    And here's the output.


    
    97 plus 3 equals 973 97 plus 3 equals 100 [output]

    If you'd prefer to do things the other way around, the next example bears careful consideration.


    <% // define variables int someNumber = 97; int aRandomNumber = 3;

    // at this stage, someNumber is still treated as a number out.println(someNumber + " plus " + aRandomNumber + " equals " + (someNumber+aRandomNumber) + "<p>");

    // now convert someNumber to a string String someString = Integer.toString(someNumber);

    // at this stage, someNumber has been converted to a string, stored in someString out.println(someString + " plus " + aRandomNumber + " equals " + (someString+aRandomNumber));

    %>


    And here's the output.


    97 plus 3 equals 100 97 plus 3 equals 973


    The upshot? parseInt() and toString() are your best friends when converting between string and numeric data types in JSP.

    More Java Articles
    More By Vikram Vaswani and Harish Kamath, (c) Melonfire


     

       

    JAVA ARTICLES

    - Adding Images With iTextSharp
    - Adding Columns With iTextSharp
    - Creating Simple PDF Files With iTextSharp
    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming
    - Gaming Development Setup





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway