What are Java Servlets?

翻译 2007年09月27日 16:39:00
   The Java Servlet API is an open standard,created by sun,for creating web applications using the Java programming language. A servlet is an object responsible for receiving a request from a client web browser and returning a response-an HTML page to be displayed in the browser.The Servlet API defines an interface and base class for servlets,as well as interfaces for several other supporting objects,such as the HttpServletRequest (which represents a request and allows the servlet to access query parameters).Vendors,both open source and proprietary,provide the actual server code and implementations of the standard interfaces.
    Servlets are most often paired with JavaServer Pages in order to generate a reponse.JSPs are a standard templating technology for servlets.A JSP is a mix of ordinary,static HTML with additional,specialized tags and directives that provide dynamic output,such as including the current user's name or the contents of an online shopping cart.Under the hood,each JSP is converted into a Java servlet that is compiled and loaded into memory.More information about servlets and JSPs is available online and in print ,including Web Development with JavaServer Pages.
    A servlet operates within a servlet container.The servlet container serves as a bridge between HTTP and the Java servlet code that you, as the developer ,will write.The servlet container is responsible for instantiating and initializing your servlets as needed.Servlet container s may be standalone,,such as Apache Tomcat,or may be one part of an  overall application server,such as BEA  WebLogic,IBM WebSphere ,or the open source JBoss application server.
    The servlet container is responsible for selecting the correct servlet to invoke based on the URL of the request;a single web application will contain many servlets.The web application's deployment descriptor gives the name and Java class for each servlet and identifies which URLs are mapped to which servlets.For example,your application may have a registration page containing an HTML form enabling new nsers to reggister .That form will submit to the addCustomer URL,which is mapped to the addCustomer servlet ,which is instantiated as the AddCustomerServlet class.The deployment descriptor will include the following elements describing the addCustomer servlet's configuration:
    As can be seen from this example,each servlet represents a particular operation within the overall web application.The AddCustomerServlet class will include code that reads the query parameters submitted with form and uses those values to create some kind of Customer object that can be stored into a database.Additional logic must decide what form of response to display-normally a confirmation page,but possibly the originalpage containing the form if an error occurred when creating the customer.

The servlets named [LogRecord] and [com.action.service.imp.LogServiceImp] are both mapped to the url

Caused by: java.lang.IllegalArgumentException: The servlets named [LogRecord] and [com.action.servic...

The servlets named [xxx] and [com.web.xxx] are both mapped to the url-pattern

因为用的是Dynamic web module version 3.0 所以Servlet被创建出来都是默认使用注解的形式 但是由于我的注解貌似无法启动 所以我手动在web.xml中配置Servlet...

maven创建Web项目启动错误The servlets named [X] and [Y] are both mapped to the url-pattern [/DemoServlet]

六月 05, 2017 3:34:34 下午 org.apache.catalina.core.AprLifecycleListener init 信息: The APR based Apache T...


  • 2010年01月15日 13:17
  • 770KB
  • 下载

What are WEP, WPA, and WPA2? Which is best?

These acronyms refer to different wireless encryption protocols that are intended to protect the inf...

hdu 1075 What Are You Talking About (字典树·文字翻译)

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1075 Description Ignatius is so lucky that he...

hdu 1075 What Are You Talking About(map)

What Are You Talking About Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K...

HDOJ What Are You Talking About

What Are You Talking About http://acm.hdu.edu.cn/diy/contest_showproblem.php?cid=12654&pid=1004 T...
您举报文章:What are Java Servlets?