1.要用servlet首先要在application中引入servlet.jar
2.然后要在.java文件中
import javax.servlet.http.httpservletrequest;
import javax.servlet.http.httpservletresponse;
import javax.servlet.http.httpservlet;
import javax.servlet.servletexception;
import java.io.ioexception;
import java.io.printwriter; //这句import可视具体情况引入
3.介绍一下servlet中的几个常用的方法
a) protected void service(httpserlvetrequest req,httpservletresponse res) throws servletexception,ioexception{}
如果被overwrite了,则可能不会调用doxxx method。
b)protected void doget(httpserlvetrequest req,httpservletresponse res) throws servletexception,ioexception{}
特征1:safe and idempotent. 2:only ascii (text) data can be sent to server with get method. 3:easy to bookmarks.
主要作用:获取数据,对数据不作改变
c)protected void dopost(httpserlvetrequest req,httpservletresponse res) throws servletexception,ioexception{}
特征1:not safe and idempotent. 2disallow bookmarks.
主要作用:传输form data,大批量的数据,常用在bbs等可改变数据存储的地方
还有一些东西下次再讲吧