Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: package statement in servlet ?


Message #1 by dion <d10n.jsp@m...> on Thu, 12 Oct 2000 10:43:10 +0700
Hello all,

I need to include package statement in my servlet,
please see the code below..
i tried the origininal HelloWorldServlet and it displays Hello World
successfully, but when i add the package com.dion.music.
it says :

javax.servlet.ServletException: HelloWorldServlet (wrong name:
com/dion/mahasiswa/HelloWorldServlet) 
java.lang.NoClassDefFoundError: HelloWorldServlet (wrong name:
com/dion/mahasiswa/HelloWorldServlet)

how to make it works?
i'm using win nt, jrun 3.0, jdk 1.3
thank you in advance.


<begin code>

/*
 * @(#)HelloWorldServlet.java   1.9 97/05/22
 * Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
 * 
 */

// i add this statement..
package com.dion.mahasiswa;
 
import java.io.*;

import javax.servlet.*;
import javax.servlet.http.*;

public class HelloWorldServlet extends HttpServlet {

    public void doGet (HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException
    {
        res.setContentType("text/html");

        ServletOutputStream out = res.getOutputStream();
        out.println("<html>");
        out.println("<head><title>Hello World</title></head>");
        out.println("<body>");
        out.println("<h1>Hello World 12:42</h1>");
        out.println("</body></html>");
    }

    public String getServletInfo() {
        return "Create a page that says <i>Hello World</i> and send it back";
    }
}

<end of code>
  

-- 
Best regards,
 dion                          mailto:d10n.jsp@m...



  Return to Index