im trying to run web.xml file and set server / server-mapping in it on tomcat. apparently the error log doesn't seem to have an error (if im not wrong) and I tried running it several times with localhost:8080/Example03/servlet1 , localhost:8080/Example03 and localhost:8080/servlet1 as i read some articles posted the new implementations on certain versions of tomcat.. only shows http error 404(status report - requested resource not available). Using v6.0.. does anyone know something I could try to make it work
Jan 08, 2014 5:59:48 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;.
Jan 08, 2014 5:59:48 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Example03' did not find a matching property.
Jan 08, 2014 5:59:48 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jan 08, 2014 5:59:48 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 494 ms
Jan 08, 2014 5:59:48 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Jan 08, 2014 5:59:48 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.26
Jan 08, 2014 5:59:48 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jan 08, 2014 5:59:48 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Jan 08, 2014 5:59:48 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/32 config=null
Jan 08, 2014 5:59:48 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 272 ms
web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<servlet>
<servlet-name>Test</servlet-name>
<servlet-class>org.test.webapp.ServletExample</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Test</servlet-name>
<url-pattern>/servlet1</url-pattern>
</servlet-mapping>
<display-name>Example03</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
re-logged:
Jan 08, 2014 7:25:41 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;.
Jan 08, 2014 7:25:41 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Example03' did not find a matching property.
Jan 08, 2014 7:25:41 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jan 08, 2014 7:25:41 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 498 ms
Jan 08, 2014 7:25:41 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Jan 08, 2014 7:25:41 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.26
Jan 08, 2014 7:25:41 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor host-manager.xml
Jan 08, 2014 7:25:42 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor manager.xml
Jan 08, 2014 7:25:42 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
Jan 08, 2014 7:25:42 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
Jan 08, 2014 7:25:42 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jan 08, 2014 7:25:42 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jan 08, 2014 7:25:42 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
Jan 08, 2014 7:25:42 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jan 08, 2014 7:25:42 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Jan 08, 2014 7:25:42 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/23 config=null
Jan 08, 2014 7:25:42 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 646 ms
class:
package org.test.webapp;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ServletExample extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException,IOException{
String name = req.getParameter("userName");
String email = req.getParameter("email");
String IP = req.getRemoteAddr();
resp.getWriter().println("<html>");
resp.getWriter().println("<head>");
resp.getWriter().println("<title>this is the response</title>");
resp.getWriter().println("</head>");
resp.getWriter().println("<body>");
resp.getWriter().println("your name is: "+ name);
resp.getWriter().println("your email is: "+ email);
resp.getWriter().println("your ip is: "+ IP);
resp.getWriter().println("</body>");
resp.getWriter().println("</html>");
}
}
index.html in WEB-INF:
<html>
<head>
<title> Test Form</title>
</head>
<body>
<form action="servlet1" method="get">
Name : <input type="text" name="name"><br>
Email : <input type="text" name="email"><br>
<input type = "submit" value="submit!">
</form>
</body>
</html>
web.xml
of the application. – Pradeep Kr Kaushal