Getting Server Error while calling Servlet from Java Application <p>Here is my Java Class by which I am calling simple servlet and passing the data, I am<br> using URL and HttpURlConnection class.What should be path of url for the servlet</p> <pre><code>public class TestJava { public static void main(String[] args) { try { URL url=new URL("http://localhost:9865/TestingServlet/PushServlet"); HttpURLConnection http_url =(HttpURLConnection) url.openConnection(); http_url.setRequestMethod("POST"); http_url.setDoOutput(true); http_url.setDoInput(true); InputStream response = http_url.getInputStream(); System.out.println(" " +response); ObjectOutputStream objOut = new ObjectOutputStream(http_url.getOutputStream()); objOut.writeObject("hello"); objOut.flush(); objOut.close(); } catch (IOException e) { e.printStackTrace(); } } } </code></pre> <p>Here is the servlet code, I am receiving the object from the java code and displaying<br> it on the console. </p> <pre><code> public class PushServlet extends HttpServlet { public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { System.out.println("HELLO This is servlet"); ObjectInputStream objIn = new ObjectInputStream(request.getInputStream()); TestJava p = null; p = (TestJava) objIn.readObject(); System.out.println("Servlet received p: "+p); } catch (Throwable e) { e.printStackTrace(System.out); } } </code></pre> <p>My web.xml is like this</p> <pre><code> &lt;welcome-file-list&gt; &lt;welcome-file&gt; Customer_Servlet &lt;/welcome-file&gt; &lt;/welcome-file-list&gt; &lt;servlet&gt; &lt;servlet-name&gt;PushServlet&lt;/servlet-name&gt; &lt;servlet-class&gt;com.servlet.PushServlet&lt;/servlet-class&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;PushServlet&lt;/servlet-name&gt; &lt;url-pattern&gt;/PushServlet&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;session-config&gt; &lt;session-timeout&gt;50&lt;/session-timeout&gt; &lt;/session-config&gt; &lt;/web-app&gt; </code></pre> <p>When i m trying to run the java code on server i.e Apache server, I'm getting<br> error HTTP Status 404 i am not able to find why i am getting this server error My code is all about invoking the servlet from java application </p> <pre><code> please help me guys . </code></pre>