Servlet Get product Information job

Source: Internet
Author: User

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "UTF-8"><title>Form</title></Head><Body><formAction= "Tijiao"Method= "POST">Add product information:<BR><BR>Product Name:<inputtype= "text"ID= "Name"name= "Name"><BR><BR>Commodity Manufacturers:<inputtype= "text"ID= "Changs"name= "Changs"><BR><BR>Service Life:<inputtype= "text"ID= "Shoum"name= "Shoum"><BR><BR>Factory Address:<inputtype= "text"ID= "Dizhi"name= "Dizhi"><BR><BR><inputtype= "Submit"value= "Submit"></form></Body></HTML>
index.html
Package Com.hanqi;import Java.io.ioexception;import Javax.servlet.servletconfig;import Javax.servlet.servletcontext;import Javax.servlet.servletexception;import Javax.servlet.http.httpservlet;import Javax.servlet.http.httpservletrequest;import Javax.servlet.http.httpservletresponse;import javax.servlet.http.httpsession;/** * Servlet Implementation class Tijiao */public class Tijiao extends HttpServlet {PR       Ivate static final Long serialversionuid = 1L;    String str = "";        /** * @see httpservlet#httpservlet () */public Tijiao () {super (); TODO auto-generated Constructor stub}/** * @see httpservlet#doget (httpservletrequest request, Httpservletre Sponse response) */public void init (ServletConfig config) throws servletexception {str = confi                            G.getinitparameter ("type");   } protected void Doget (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException {              if (Str.equals ("1")) {response.setcharacterencoding ("GBK");                        String StrName =new string (request.getparameter ("name"). GetBytes ("Iso-8859-1"), "UTF-8");                        String Strchangs =new string (Request.getparameter ("Changs"). GetBytes ("Iso-8859-1"), "UTF-8");                        String Strshoum =new string (Request.getparameter ("Shoum"). GetBytes ("Iso-8859-1"), "UTF-8");                        String Strdizhi =new string (Request.getparameter ("Dizhi"). GetBytes ("Iso-8859-1"), "UTF-8");            if (StrName = = NULL | | Strname.trim (). Length () ==0) {Response.getwriter (). Append ("Product name cannot be empty"); } else if (strchangs = = NULL | | Strchangs.trim (). Length () ==0) {response.ge            Twriter (). Append ("Commodity manufacturers cannot be empty"); } else if (Strshoum = = NULL | | Strshoum.trim (). Length () ==0) {response.getwriter (). AP      Pend ("Service life cannot be empty");      } else if (Strdizhi = = NULL | | Strdizhi.trim (). Length () ==0) {Response.getwrite            R (). Append ("Factory address cannot be empty");                } else {Response.getwriter (). Append ("Product Name:" + strName); Response.getwriter (). Append ("<BR>Commodity Manufacturers: "+strchangs); Response.getwriter (). Append ("<BR>Service Life: "+strshoum); Response.getwriter (). Append ("<BR>Factory Address: "+strdizhi";    }//response.getwriter (). Append ("Served at:asd"). Append (Request.getcontextpath ()). append (str);    } else {Response.getwriter (). Append ("Served at:123"). Append (str); }}/** * @see httpservlet#dopost (httpservletrequest request, httpservletresponse response) */Protec  Ted void DoPost (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException {//    TODO auto-generated Method Stub doget (request, response); }}
Tijiao.java

Servlet Get product Information job

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.