当前位置: 技术问答>java相关
servlet的请教
来源: 互联网 发布时间:2015-04-28
本文导语: 配置: win2000+jdk2.1.3+tomcat4.0 编写一个可以输出html的servlet package hall; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloWWW extends HttpServlet { public void doGet(HttpServletRequest request, ...
配置:
win2000+jdk2.1.3+tomcat4.0
编写一个可以输出html的servlet
package hall;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWWW extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n" +
"<HTML>\n" +
"<HEAD><TITLE>Hello WWW</TITLE></HEAD>\n" +
"<BODY>\n" +
"<H1>Hello WWW</H1>\n" +
"</BODY></HTML>");
}
}
怎么配置tomcat才能运行这个servlet,用不用下载其它的东东
win2000+jdk2.1.3+tomcat4.0
编写一个可以输出html的servlet
package hall;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWWW extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n" +
"<HTML>\n" +
"<HEAD><TITLE>Hello WWW</TITLE></HEAD>\n" +
"<BODY>\n" +
"<H1>Hello WWW</H1>\n" +
"</BODY></HTML>");
}
}
怎么配置tomcat才能运行这个servlet,用不用下载其它的东东
|
要在tomcat中运行要把编译出来的class放到Webapp目录,改写web.xml.
|
jdk 1.3编译不了servlet。它没有servlet的包。
下载一个J2EE就行。
下载一个J2EE就行。
|
j2se没有servlet包也犯不着下载j2ee吧,可以在tomcat下找到的