Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
262
Chapter 11 The JSP page Directive: Structuring Generated Servlets
Listing 11.5 ComputeSpeed.jsp (continued)
  
      Computing Speed
<%! 
// Note lack of try/catch for NumberFormatException if
// value is null or malformed.
private double toDouble(String value) {
  return(Double.valueOf(value).doubleValue());
}
%>
<% 
double furlongs = toDouble(request.getParameter("furlongs")); 
double fortnights = toDouble(request.getParameter("fortnights"));
double speed = furlongs/fortnights;
%>
  
  • Distance: <%= furlongs %> furlongs.
  •   
  • Time: <%= fortnights %> fortnights.
  •   
  • Speed: <%= speed %> furlongs per fortnight.
  • Listing 11.6 SpeedErrors.jsp  
    Error Computing Speed
          HREF="JSP Styles.css"
          TYPE="text/css">
    <%@ page isErrorPage="true" %>
    Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
    Servlet and JSP training courses by book's author: courses.coreservlets.com.
    
    
    
    
    
    
    footer
    
    
    
    
    

     

     

     

     

     Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

    jsp web hosting

     

    Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

    Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved