Results 1 to 4 of 4

Thread: Tomcat 404 on servlet request

  1. #1
    Join Date
    Jul 2009

    Tomcat 404 on servlet request

    Hello all,

    I have installed xampp on machine running Windows 7 Home Premium, including tomcat plugin

    They have all installed successfully and all will turn on.

    When visiting http://localhost:8080/ I see a blank white page (but it has the tomcat favicon)

    When running the example from the following website, it works:

    I have created a servlet with the following code (it compiles):

    package base;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.sql.*;
     * Servlet implementation class FirstServlet
    public class FirstServlet extends HttpServlet {
    	private static final long serialVersionUID = 1L;
    	private String text = "";
         * @see HttpServlet#HttpServlet()
        public FirstServlet() {
            // TODO Auto-generated constructor stub
        protected void mysql_connect() {
        	Connection con = null;
            try {
              con = DriverManager.getConnection("jdbc:mysql://localhost/test", "root", "woops forgot to remove this the first time");
              if(!con.isClosed()) {
                text = "Successfully connected to MySQL server using TCP/IP...";
            } catch(Exception e) {
              text = "Exception: " + e.toString();
            } finally {
              try {
                if(con != null)
              } catch(SQLException e) {
            	  text = e.getMessage();
    	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    		PrintWriter out = response.getWriter();
    		out.println("This is my first servlet<br/>");
    	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    		// TODO Auto-generated method stub
    This class is located in : C:\xampp\tomcat\webapps\Servlet\WEB-INF\classes\base\

    The mysql-connector is in the lib folder of the web application

    This is the web.xml file (which is located in ""\Servlet\WEB-INF):

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    However when I visit:

    I get a tomcat error 404 page stating the requested resource is not available

    As you can probably tell, I'm fairly new with tomcat and java, and don't really understand how it works. If someone could point out what I'm missing I would appreciate it very much.

    When the tomcat server is started, it automatically configures the mod_jk file to add a jkmount rule to whatever directories are in the webapps folder

    Also, I have another tomcat isntallation in C:\tomcat, which Eclipse is configured to use, if I turn the xampp tomcat server off, and eclipse starts the other server, I can go to:
    http://localhost:8080/Servlet/FirstServlet and it works.

    Just thought of something, I had to add another tomcat "installation" because when I tried to get eclipse to use the C:\xampp\tomcat folder it would, I forget exactly why.

    Thanks in advance
    Last edited by ntk418; 06-04-2010 at 01:02 PM.

  2. #2
    Join Date
    Jul 2009
    Problem solved. Not sure what I did to solve it or I would post the solution. Was just errors on my part.

  3. #3
    Join Date
    Jul 2009

    I believe that was the problem.

  4. #4
    Join Date
    May 2011

    Help plz


    im a complete noob in java.

    if i have to modify this program to request a web page from the tomcat server,what codes must i use?

    please help me out..

    even if i have to get the answer from the server as html codes and then display the codes..
    ( i mean,not displaying the actual web page in the java program,but getting the tag like <html><body> etc )

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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