
hi all Friends
I am stuck using the java servlets and problem raise for classpath.
I had a problem with servlet to call a class because when i complied my servlet class file it give me error that it didn't found any java class (which is java class calling from servlet).
but i solved this problem by putting the path of classes to the classpath and then it worked fine after doing that and my all files compiled fine and my project worked.
But now i am again trying another project and trying to compile this project but got same problem again. Now this time i doing the all procedure for setting the classpath to solve the problem as i solved for previous project. but this time my classpath solution is not working for this project and i am trying this procedure again and again but i don't know i am stuck please help me friends
thanks in advance SANTBIR SINGH

Put servlet-api.jar inside the lib folder of apache tomcat.
1)create a servlet.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<html>");
pw.println("<head><title>Hello World</title></title>");
pw.println("<body>");
pw.println("<h1>Hello World</h1>");
pw.println("</body></html>");
}
}
2)Go to the webapps folder of your apache tomcat and create a web application folder but it should having an appropriate name like examples.
3)Create web.xml and classes folder inside the WEB_INF folder of web application folder.
4)Copy the servlet to the classes folder.
5)Edit the web.xml to include servlet?s name and url pattern.
<servlet> <servlet-name>HelloWorld</servlet-name> <servlet-class>HelloWorld</servlet-class> </servlet> <servlet-mapping> <servlet-name>HelloWorld</servlet-name> <url-pattern>/HelloWorld</url-pattern> </servlet-mapping>
6)Compile your servlet.
7)Run Tomcat server by clicking the startup.bat file. This is located inside the bin folder of apache tomcat.
8)Open the browser and type the following url:
http://localhost:8080/webapplicationfolder_name/HelloWorld
For more information, please go through the following links:
http://www.roseindia.net/servlets/introductiontoconfigrationservlet.shtml
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.