In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to use Servlet". Friends who are interested might as well take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn how to use Servlet.
The development environment needed to write Servlet
The basic environment required for Servlet development is JSDK and a Web server that supports Servlet.
1.JSDK (Java Servlet Development Kit)
JSDK contains the Java class libraries and related documentation needed to compile Servlet applications. For users developing with Java 1.1, JSDK must be installed. JSDK has been integrated into Java 1.2 Beta version, and if you develop with Java 1.2 or above, you do not need to install JSDK.
two。 Web server that supports Servlet
Servlet needs to run on a Web server that supports Servlet. Currently supports Servlet's Web server SUN's JSWDK1.0.1. If the existing Web server does not support Servlet, you can use some third-party server add-ons (add-ons) to make the Web server support Servlet, in which Live Software company provides a product called JRun, by installing the corresponding version of JRun, you can make Microsoft IIS and Netscape Web Server support Servlet.
The process of developing Servlet
Here is a simple Servlet example to illustrate the process of developing Servlet.
1. Write Servlet code
Java Servlet API is a standard Java extension package that contains two Package ∶ javax.servlet and javax.servlet.http. For developers who want to develop custom protocols based on customers, they should use the classes and interfaces in the javax.servlet package; for developers who only use the HTTP protocol to interact with the client, they only need to use the classes and interfaces in the javax.servlet.http package for development.
The following is a servlet program code (RequestInfoExample.java) ∶
Import java.io.*; import java.servlet.*; import javax.servlet.*; public class RequestInfoExample 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 > Request Information Example < / title >") Out.println ("< / head >"); out.println ("< body >"); out.println ("< h4 > Request Information Example < / h4 >"); out.println ("Method:" + request.getMethod ()); out.println ("RequestURI:" + request.getRequestURI ()); out.println ("Protocol:" + request.getProtocol ()); out.println ("PathInf" + request.getPathInfo ()) Out.println ("Remote Address:" + request.getRemoteAddr ()); out.println ("< / body >"); out.println ("< / html >");} public void doPost (HttpServletRequest request, HttpServletResponse res) throws IOException, ServletException {doGet (request, response);}} so far, I believe you have a deeper understanding of "how to use Servlet", you might as well do it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
This article is about how to use Android to imitate Wechat network to load pop-up boxes. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look. 1. Customize the style style of view
Wechat
About us
Contact us
Product review
car news
thenatureplanet
More Form oMedia:
AutoTimes.
Bestcoffee.
SL News.
Jarebook.
Coffee Hunters.
Sundaily.
Modezone.
NNB.
Coffee.
Game News.
FrontStreet.
GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.