Simple example of Servlet

MyPlanet 2002-11-14 09:33:50
I am learning JAVA. Can you tell me where I can find a simple example how to create Servlet and use it in JSP?
...全文
44 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuw 2002-11-15
  • 打赏
  • 举报
回复
不知你用什么服务,但用tomcat是最简单的了.
那里有很多例子可用:
http://localhost:8080/examples/servlets/index.html
HawaiiLeo 2002-11-15
  • 打赏
  • 举报
回复
Tomcat 中例子
C:\Tomcat4.1\webapps\examples\servlets

如helloworld.html
=====================================
Source Code for HelloWorld Example

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

public class HelloWorld extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<head>");
out.println("<title>Hello World!</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello World!</h1>");
out.println("</body>");
out.println("</html>");
}
}
alsoran 2002-11-14
  • 打赏
  • 举报
回复
www.servletforum.com
longlink 2002-11-14
  • 打赏
  • 举报
回复
use Tomcat and it will give you some example.

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧