Getting started with Java Web server using servlets

Baidu Encyclopedia says:

Servlet (server applet) is the abbreviation of java servlet, which is called small service program or service connector. The main function of server-side program written in Java is to interactively browse and modify data and generate dynamic web content.

Popular method:

Is a short Java program running on the server side to accept and respond to requests sent from the client

effect:

翻译错误 Invalid Access Limit

Write a serclet step

1. Write a class

Inherited from httpservlet

Override doget and dopost methods

2. Write a configuration file (web. XML)

Register before binding

3. Visit

http://localhost/ Project name / path

be careful:

Receiving parameter: Format: value = key

String value = request. getParameter("key");

For example: http://localhost/day09/hello?username=tom

String value = request getParameter("username");

Write back parameters:

response. getWriter(). print("success");

Handling garbled code in response:

resp. setContentType("text/html;charset=utf-8"); Usually on the first line

The following is the original code:

web. XML configuration

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>