Ajax in the use of jquery (Load method exercises)

Source: Internet
Author: User
Tags stub

1.index.html

<! DOCTYPE html>  

Loadservlet.java

Package com.haige;
Import java.io.IOException;

Import Java.io.PrintWriter;
Import javax.servlet.ServletException;
Import Javax.servlet.annotation.WebServlet;
Import Javax.servlet.http.HttpServlet;
Import Javax.servlet.http.HttpServletRequest;

Import Javax.servlet.http.HttpServletResponse; @WebServlet ("/loadservlet") public class Loadservlet extends HttpServlet {private static final long Serialversionuid
    = 1L;
        Public Loadservlet () {super (); TODO auto-generated constructor stub} protected void Doget (HttpServletRequest request, HttpServletResponse Res Ponse) throws Servletexception, IOException {//TODO auto-generated Method Stub Response.setcontenttype ("Tex
     T/html;charset=utf-8 ");
     Response.setcharacterencoding ("Utf-8");
     PrintWriter out =response.getwriter ();
     Out.println ("<ul id= ' Myul ' >");
     Out.println ("<li id= ' Myli ' > Beijing </li>");
     OUT.PRINTLN ("<li> Shanghai </li>"); Out.println ("<li>Nanjing </li> ");
     Out.println ("</ul>");
    Out.close ();  } protected void DoPost (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException
        {//TODO auto-generated Method Stub request.setcharacterencoding ("Utf-8");
        String Username=request.getparameter ("username");
        int Age=integer.parseint (Request.getparameter ("Age"));
        Response.setcharacterencoding ("Utf-8");
        PrintWriter out =response.getwriter ();
        Out.println ("<p> My name is:" +username+ ", this year" +age+ "years old </p>");
    Out.close (); }

}

Screenshots:


Related Article

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.