• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to set environment variables for running a servlet program?  RSS feed

 
ajit chaudhary
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

tell me about how to set the environment variables and how to run a servlet program on tomcat?
I tried this on my computer and this message shows in the command line....

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class TinyServ extends HttpServlet {

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();

out.println("<html>");
out.println("<head>");
out.println("<title>Well House Consultants #1 Servlet</title>");
out.println("</head>");
out.println("<body bgcolor=\"white\">");
out.println("<h1>Greetings from Well House Consultants</h1>");
out.println("This is the page body</body>");
out.println("</html>");
}
}

To compile :javac TinyServ.java
to run : java TinyServ
and the this error message appears:
Exception in thread "main" java.lang.NoSuchMethodError: main
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch
you cant call servlet. container takes care about servlet . by the way link below may through some light. search google to get some basic idea.

http://www.coderanch.com/t/361369/Servlets/java/execute-servlet-program
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read. You can edit your post by using the button.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!