Results 1 to 3 of 3
  1. #1
    vknehra10 is offline Member
    Join Date
    Dec 2016
    Rep Power

    Default GET error even if we are using POST

    i am using servlet and in my html file i create a form its method is POST and i am using doPost meethod in my program too , but whenever i run my program it showing Error 500 and then i replace the method with doGet it runs perfectly why?

    Java Code:
    <div class="reg">
    <div style="color:black; margin-left:55px; padding-top:10px;"><h1>Register Your Account</h1></div>
    <form action="Register" class="regf" method="post">
    <p style="font-size:12px; padding-top:10px; margin-left:130px;">First Name</p><br />
    <input type="text" name="fname" placeholder="First Name"/><br />
    <p style="font-size:12px; padding-top:10px; margin-left:130px;">Middle Name</p><br />
    <input type="text" name="mname" placeholder="Middle Name"/><br />
    <p style="font-size:12px; padding-top:10px; margin-left:130px;">Last Name</p><br />
    <input type="text" name="lname" placeholder="Last Name"/><br />
    <p style="font-size:12px; padding-top:10px; margin-left:130px;">Username</p><br />
    <input type="text" name="usrname" placeholder="Username"/><br />
    <p style="font-size:12px; padding-top:10px; margin-left:130px;">Password</p><br />
    <input type="text" name="passwd" placeholder="Password"/><br />
    <input type="submit" value="Register Me !" style="margin-left:120px; margin-top:50px; background:#202020;color:#F29C28; padding:18px 140px; margin-left:0px; font-size:20px; border:1px solid #202020; cursor:pointer;"/>

    Java Code:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class Register extends HttpServlet{
    public void doPost(HttpServletRequest req, HttpServletResponse res)throws IOException,ServletException{
    PrintWriter pw=res.getWriter();
    String fn=req.getParameter("fname");
    String mn=req.getParameter("mname");
    String ln=req.getParameter("lname");
    String un=req.getParameter("usrname");
    String ps=req.getParameter("passwd");


  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: GET error even if we are using POST

    There will be a stack trace somewhere in the server logs, showing you where exactly there has been an error.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    The Netherlands
    Rep Power

    Default Re: GET error even if we are using POST

    Error 500 means there was an error at the server side. Make sure you have logging in all your catch-blocks. If you are using Internet Explorer, you might need to disable "friendly http messages" since that will hide the real error from you.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

Similar Threads

  1. Replies: 5
    Last Post: 09-26-2016, 02:37 PM
  2. writing body in post throws error
    By aakhan2021 in forum New To Java
    Replies: 2
    Last Post: 08-01-2016, 11:36 AM
  3. Replies: 0
    Last Post: 02-05-2014, 08:33 AM
  4. Replies: 3
    Last Post: 05-04-2009, 04:15 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts