当前位置: 技术问答>java相关
Simple example of Servlet
来源: 互联网 发布时间:2015-11-03
本文导语: I am learning JAVA. Can you tell me where I can find a simple example how to create Servlet and use it in JSP? | Tomcat 中例子 C:Tomcat4.1webappsexamplesservlets 如helloworld.html ===================================== Sourc...
I am learning JAVA. Can you tell me where I can find a simple example how to create Servlet and use it in JSP?
|
Tomcat 中例子
C:Tomcat4.1webappsexamplesservlets
如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("");
out.println("");
out.println("");
out.println("Hello World!");
out.println("");
out.println("");
out.println("Hello World!");
out.println("");
out.println("");
}
}
C:Tomcat4.1webappsexamplesservlets
如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("");
out.println("");
out.println("");
out.println("Hello World!");
out.println("");
out.println("");
out.println("Hello World!");
out.println("");
out.println("");
}
}
|
不知你用什么服务,但用tomcat是最简单的了.
那里有很多例子可用:
http://localhost:8080/examples/servlets/index.html
那里有很多例子可用:
http://localhost:8080/examples/servlets/index.html
|
use Tomcat and it will give you some example.
|
www.servletforum.com
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。