社区
Web 开发
帖子详情
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
打赏
收藏
Simple example of Servlet
I am learning JAVA. Can you tell me where I can find a simple example how to create Servlet and use it in JSP?
复制链接
扫一扫
分享
转发到动态
举报
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.
简单
servlet
程序
在这个例子中,当用户通过GET方式访问这个
Servlet
时,服务器将返回"Hello, this is a
simple
servlet
example
!"。 4. **配置web.xml**: ```xml <
servlet
> <
servlet
-name>
Simple
Servlet
</
servlet
-name> ...
servlet
简单示例
<
servlet
-class>com.
example
.
Simple
Servlet
</
servlet
-class> </
servlet
> <
servlet
-mapping> <
servlet
-name>
Simple
Servlet
</
servlet
-name> <url-pattern>/
simple
</
servlet
-mapping> ``` 这样配置后,当用户...
简单的web开发——
servlet
案例
<
servlet
-class>com.
example
.
Simple
Servlet
</
servlet
-class> </
servlet
> <
servlet
-mapping> <
servlet
-name>
Simple
Servlet
</
servlet
-name> <url-pattern>/
simple
</
servlet
-mapping> ``` 这将把URL路径`/...
创建简单
servlet
<
servlet
-class>com.
example
.
Simple
Servlet
</
servlet
-class> </
servlet
> <
servlet
-mapping> <
servlet
-name>
Simple
Servlet
</
servlet
-name> <url-pattern>/
simple
</
servlet
-mapping> ``` 这意味着,访问`...
servlet
技术
<
servlet
-class>com.
example
.
Simple
Servlet
</
servlet
-class> </
servlet
> <
servlet
-mapping> <
servlet
-name>
Simple
Servlet
</
servlet
-name> <url-pattern>/
simple
</
servlet
-mapping> ``` 这样,当用户访问`/
simple
...
Web 开发
81,122
社区成员
341,744
社区内容
发帖
与我相关
我的任务
Web 开发
Java Web 开发
复制链接
扫一扫
分享
社区描述
Java Web 开发
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章