G
gert
I am trying to do a httprequest to a servlet but i always get 404 from
the server ?
url = POST http://localhost:8001/appointment.do
servlet =
package response;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class appointment extends HttpServlet {
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/xml;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet appointment</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet appointment at " +
request.getContextPath () + "</h1>");
out.println("</body>");
out.println("</html>");
} finally {
out.close();
}
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
public String getServletInfo() {
return "Short description";
}
}
the server ?
url = POST http://localhost:8001/appointment.do
servlet =
package response;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class appointment extends HttpServlet {
protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/xml;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet appointment</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet appointment at " +
request.getContextPath () + "</h1>");
out.println("</body>");
out.println("</html>");
} finally {
out.close();
}
}
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
public String getServletInfo() {
return "Short description";
}
}