JAVA一步一步的WEB编程关于SERVLET〈二〉

时间:2010-01-16 09:11:19   来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:在就,语言本身STUDY这里有一些例子,先看看: //Hello.classimport java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class Hello extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) ...
  正文:

上次说到JAVA一步一步的WEB编程关于JSP与JavaBean 现在说SERVLET,由与内容多所以分几章来说SERVLET〈一〉它与别的CGI程序不同的是,它有强大的J2EE做后,配合JSP,JAVABEAN,连接EJB,等更高一级的应用,这里慢慢说来,不同的SERVLET服务器配置,不同,现在就,语言本身STUDY这里有一些例子,先看看:


 //Hello.classimport java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class Hello extends Httphotoshop/ target=_blank class=infotextkey>pservlet {  public void doGet(HttpServletRequest req, HttpServletResponse res)                               throws ServletException, IOException {    res.setContentType("text/html");    PrintWriter out = res.getWriter();    String name = req.getParameter("name");    out.println("<HTML>");    out.println("<HEAD><TITLE>Hello, " + name + "</TITLE></HEAD>");    out.println("<BODY>");    out.println("Hello, " + name);    out.println("</BODY></HTML>");  }  public String getServletInfo() {    return "A servlet that knows the name of the person to whom it's" +            "saying hello";  }}//HelloWorld.class//-------------------------------import java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class HelloWorld extends HttpServlet {  public void doGet(HttpServletRequest req, HttpServletResponse res)                               throws ServletException, IOException {    res.setContentType("text/html");    PrintWriter out = res.getWriter();    out.println("<HTML>");    out.println("<HEAD><TITLE>Hello World</TITLE></HEAD>");    out.println("<BODY>");    out.println("<BIG>Hello World</BIG>");    out.println("</BODY></HTML>");  }}//------------------------//form.html<HTML><HEAD><TITLE>Introductions</TITLE></HEAD><BODY><FORM METHOD=GET ACTION="/servlet/Hello">If you don't mind me asking, what is your name?<INPUT TYPE=TEXT NAME="name"><P><INPUT TYPE=SUBMIT></FORM></BODY></HTML>先配置一下,注意,SERVLET CLASS 放在,servlets 下,访问时,servlet下访问我这里简单放在examples下了C:/jakarta-tomcat-3.3a/webapps/examples/WEB-INF/classes/上面的CLASS访问的SERVLET class 如下http://localhost:8080/examples/servlet/...
写于02年10月 newless


来源:http://www.002pc.com/master/College/Programming/JSP/11923.html

收藏到:

关于《JAVA一步一步的WEB编程关于SERVLET〈二〉》文章的评论

共有 0 位网友发表了评论 此处只显示部分留言 点击查看完整评论页面

随机文章

    SQL Error: select * from ***_ecms_article where classid='85' and checked=1 order by rand() limit 10

顶出来的热门

    SQL Error: select * from ***_ecms_article where classid='85' and checked=1 order by diggtop desc,id desc limit 10
站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td