Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <title>Handling an HTTP Get Request</title>
- </head>
- <body>
- <form action = "/WelcomeServlet/welcome1" method = "get">
- <p><label>Click the button to invoke the servlet
- <input type = "submit" value = "Get HTML Document" />
- </label></p>
- </form>
- </body>
- </html>
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
- <display-name>WelcomeServlet</display-name>
- <welcome-file-list>
- <welcome-file>index.html</welcome-file>
- <welcome-file>index.htm</welcome-file>
- <welcome-file>index.jsp</welcome-file>
- <welcome-file>default.html</welcome-file>
- <welcome-file>default.htm</welcome-file>
- <welcome-file>default.jsp</welcome-file>
- </welcome-file-list>
- </web-app>
- package welcomeServlet;
- import java.io.IOException;
- import java.io.PrintWriter;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- public class WelcomeServlet extends HttpServlet {
- private static final long serialVersionUID = 1L;
- protected void doGet( HttpServletRequest request, HttpServletResponse response )
- throws ServletException, IOException
- {
- response.setContentType ( "text/html");
- PrintWriter out = response.getWriter();
- out.println("<?xml version = \"1.0\"?>");
- out.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD " +
- "XHTMS 1.0 String//EN\" \"http://www.w3.org" +
- "/TR/xhtml/DTD/xhtml1-strict.dtd\">");
- out.println(
- "<html xmlns = \"http://www.w3.org/1999/xhtml\">");
- // head section of document
- out.println( "<head>");
- out.println( "<title>A Simple Servlet Example</title>");
- out.println( "</head>");
- // body section of document
- out.println( "<body>");
- out.println( "<h1>Welcome to Servlets!</h1>");
- out.println("<?body>");
- // end Xhtml document
- out.println( "</html>'");
- out.close(); // close stream to complete the page
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment