Results 1 to 2 of 2

Thread: Servlet mapping

  1. #1
    cozsmin is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

    Default Servlet mapping

    Hello

    I have tomcat 6.0 on windows xp , jdk 1.5

    I made a simple servlet
    /webapps/my/WEB-INF/web.xml :
    Java Code:
    <web-app>
    
    <servlet>
    	<servlet-name>my</servlet-name>
    	<servlet-class>my.Servlet</servlet-class>
    </servlet>
    
    <servlet-mapping>
    	<servlet-name>my</servlet-name>
    	<url-pattern>/</url-pattern>
    </servlet-mapping>
    
    
    <welcome-file-list>
    	<welcome-file>index.html</welcome-file>
    </welcome-file-list>
    
    </web-app>
    and the servlet class :
    /webapps/my/WEB-INF/classes/my/Servlet.java
    Java Code:
    package my;
    
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import java.io.PrintWriter; 
    public class Servlet extends HttpServlet {
    
    	PrintWriter out;
    	public void doGet (HttpServletRequest rq, HttpServletResponse rs) throws java.io.IOException {
    		doPost (rq,rs);
    	}
    	
    	public void doPost (HttpServletRequest request, HttpServletResponse response) throws java.io.IOException {
    		respond(request,response);
    	}
    	
    	public void respond (HttpServletRequest request, HttpServletResponse response) throws java.io.IOException {
    		out.print("testing");
    	}
    }
    I get from http:://localhost/my the following :
    Java Code:
    java.lang.NullPointerException
    	my.Servlet.respond(Servlet.java:22)
    	my.Servlet.doPost(Servlet.java:17)
    	my.Servlet.doGet(Servlet.java:13)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    and the tomcat widow says :
    Java Code:
    INFO:Reloading context [/my]
    CONTAINER org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/my] has not been started
    I guess it cannot instantiate the my.Servlet but I have no ideea why
    Last edited by cozsmin; 04-04-2009 at 09:49 AM.

  2. #2
    cozsmin is offline Member
    Join Date
    Apr 2009
    Posts
    2
    Rep Power
    0

Similar Threads

  1. xml mapping error with JPA in RAD, RSA
    By ishakteyran in forum Other IDEs
    Replies: 0
    Last Post: 02-05-2009, 09:00 PM
  2. xml mapping error with JPA
    By ishakteyran in forum XML
    Replies: 0
    Last Post: 02-05-2009, 08:59 PM
  3. Help with image mapping
    By coco in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 05:06 AM
  4. About servlet-mapping
    By Heather in forum Java Servlet
    Replies: 1
    Last Post: 07-14-2007, 07:00 PM

Posting Permissions

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