首页 > 编程 > JSP > 正文

jsp源码实例1(输出)

2024-09-05 00:20:48
字体:
来源:转载
供稿:网友

package coreservlets;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

/** Simple servlet that generates HTML.
* <P>
* Taken from Core Servlets and JavaServer Pages
* from Prentice Hall and Sun Microsystems Press,
* http://www.coreservlets.com/.
* © 2000 Marty Hall; may be freely used or adapted.
*/

public class HelloWWW2 extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String docType =
"<!DOCTYPE HTML PUBLIC /"-//W3C//DTD HTML 4.0 " +
"Transitional//EN/">/n";
out.println(docType +
"<HTML>/n" +
"<HEAD><TITLE>Hello WWW</TITLE></HEAD>/n" +
"<BODY>/n" +
"<H1>Hello WWW</H1>/n" +
"</BODY></HTML>");
}
}

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表