Hello peeps,

I want to test out this program but i am having problems!

each time i run it - it goes

" java.lang.NoSuchMethodError: main
Exception in thread "main" "

I know why i am having this error - coz i am missing my "public static void ....."

But the real problem i am having is - calling the method to the main class ! sorri i am beginner - so plz be gentle !

here is the code !

public class h extends HttpServlet {


  protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        //
        // Get client's IP address
        //
        String clientIP = request.getRemoteAddr();

        //
        // Get client's host name
        //
        String clintHost = request.getRemoteHost();

        //response.setContentType("text/plain");
        PrintWriter out = response.getWriter();
        out.println("IP  : " + clientIP);
        out.println("Host: " + clintHost);        
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request, response);
    }

i have tried doing

public static void main (String []arg){
    h method = new h();

    System.out.println(clientIP);
}

but of course its error - i no its a simple problem !:$

Thanks :)

OK, so you had a problem, but you've fixed it, and now you have another error, but you haven't told us what it is. You have at least two sections of code, but we don't know how you fitted them together.
So what you have to do is start again and tell us EXACTLY what the problem is. If there's an error message post its entire complete text. Post all the relevant code in one piece exactly as you compiled it.
Anyway, it's an HttpServlet so you should have a web server somewhere that will call your servlet when an appropriate HTTP request comes in.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.