Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
2.5 Simple HTML Building Utilities
33
ing 2.6, with Listing 2.7 showing a variation of 
HelloWWW2
 that makes use of
this utility. I'll add a few more utilities throughout the book.  
Listing 2.6 ServletUtilities.java 
package coreservlets;
import javax.servlet.*;
import javax.servlet.http.*;
public class ServletUtilities {
  public static final String DOCTYPE =
    "
    "Transitional//EN\">";
  public static String headWithTitle(String title) {
    return(DOCTYPE + "\n" +
           "\n" +
           "" + title + "\n");
  }
...
}
Listing 2.7 HelloWWW3.java 
package coreservlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWWW3 extends HttpServlet {
  public void doGet(HttpServletRequest request,
                    HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println(ServletUtilities.headWithTitle("Hello WWW") +
                "\n" +
                "

Hello WWW

\n" +
                "");
  }
}
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