New to JavaEE, need help on doGet() and doPost()

Discussion in 'Java JSP/Servlet' started by titi3000, Oct 21, 2014.

  1. titi3000

    titi3000 New Member

    Hi all,
    I'm writing a basic codes in javaEE, when I added these codes to doGet()


    PrintWriter out = response.getWriter();
    out.println("<html><body><h1>The square root of 4.0 is: " + Math.sqrt(4.0) + "</h1></body></html>");


    Eclipse will print out something, like "The square root of 4.0 is 2.0", but when I add these to doPost(), Eclipse print out nothing.
    Please tell me why, and in what case we use doGet() or doPost()? As I know doGet() and doPost is similar, but doGet() is not safe(password...) and very limited while doPost() is more powerful. Please tell me when to use doGet() and when to use doPost().
    Thank you very much!
     

Share This Page