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

View Answers

July 20, 2012 at 3:25 PM

Put servlet-api.jar inside the lib folder of apache tomcat.

1)create a servlet.

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

public class HelloWorld extends HttpServlet{ 
  public void doGet(HttpServletRequest request, HttpServletResponse response)
                                   throws ServletException,IOException{
    PrintWriter pw = response.getWriter();
    pw.println("<head><title>Hello World</title></title>");
    pw.println("<h1>Hello World</h1>");

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.


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:


For more information, please go through the following links:


Related Tutorials/Questions & Answers:
JAVA CLASSPATH PROBLEM  hi all Friends I am stuck using the java servlets and problem raise for classpath. I had a problem with servlet to call... solved this problem by putting the path of classes to the classpath
running java with classpath in cygwin
running java with classpath in cygwin  The following command works in cmd.exe but failts in cygwin shell. java -cp .;oracle.jar;mysql.jar Executecmd query value; how should i alter the command to run in the bash shell?thanks
java classpath prbm in windows 7
java classpath prbm in windows 7  i have a problem to set the classpath in windows7 in my system oracle is not there. environment variables under that user variables i set them like this: CLASS .;C:\Program Files\Java\jdk1.6.0_32
Java ClassPath
Java ClassPath      ... numerous directories and JAR archives. The -classpath option to javac and java.... i.e.classpath  C:\Java\jdk1.6.0_03\lib For setting CLASSPATH using
How to set CLASSPATH in Java?
;    In Java you have to set PATH and CLASSPATH variables.... The -classpath option to javac and java allows multiple entries to be specified...; In JDK the CLASSPATH contains directories (or JAR files), from where your java
path classpath
be in path. While Classpath is Enviroment Variable that tells JVM or Java Tools where...path classpath  EXPLAIN PATH AND CLASSPATH ? DIFF send me ans plz...:// Thanks
java Problem
java Problem  I want to create a binary tree for displaying members in Downline. i am creating a site for MLM(Multi-Level MArketing). tree must be dynamically populated from database. is there any help for me. Thanks in advance
JAVA Problem
JAVA Problem  Write a program that takes two parameters 1. a word 2. an array of words It should then remove all instances of the word in the array. For Example: INPUT word="ravi" word_array = ["Chethan Bhagat
Maven dependency for com.portingle - classpath-hell version 1.2 is released. Learn to use classpath-hell version 1.2 in Maven based Java projects
use this version ( com.portingle - classpath-hell version 1.2 ) in their Java... that downloads and includes  com.portingle - classpath-hell version 1.2 java library...Maven dependency for  com.portingle  - Version 1.2 of classpath-hell
resolution problem in java
resolution problem in java  I designed project in java in my PC when run the same project in some other PC i can't fully view my java forms.Some said that it is resolution problem
Problem in uploading java application
Problem in uploading java application  I have uploaded my java application (folder created under webapps) using Filezilla FtpClient.Application... this problem
for a problem in coading - Java Beginners
for a problem in coading  what is the problm in following coading...(String[] args) { mywindow (); } }   Hi Friend, There is no problem... Run : java mywindows Thanks RoseIndia Team
Problem on JAVA Programme
Problem on JAVA Programme  public class AA { int add(int i) { int y = i; y += 20; if (y <= 100){ y +=30;add(y);} System.out.println("Final Value of y : " + y); return y; } public static void main
Java implementation problem
/answers/viewqa/Java-Beginners/28578-java-implementation-problem-.html...Java implementation problem  I want to implement following in java... problem in your post previews. please consider 1. 2. points just after main
java implementation problem
java implementation problem   I want to implement following in java code : Main thread Create three threads wait for completion of stage 2 of all three threads Access all three local variable (LC0, LC1, LC2) of threads bulid
Basic problem for Java experts
Basic problem for Java experts  This assignment will test your knowledge of Arrays Array searching Array sorting Array processing Specification An athletics club require a simple statistical analysis program for analysing lap
Installing the Driver and Configuring the CLASSPATH
Installing the Driver and Configuring the CLASSPATH  What is the procedure to Installing the Driver and Configuring the CLASSPATH mysql jdbc connector? the jar file
java problem - Java Beginners
java problem  Write a program that could be used to help children...(); System.out.print("How many problems would you like? "); double q = scan.nextDouble(); System.out.println(); double r=0,w=0; for (int idx = 1; idx <= q
classpath and path for structs1.3.8
classpath and path for structs1.3.8  How to set classpath and path for structs1.3.8 ?   just add struts-core-1.3.8.jar file to CLASSPATH or ext folder of jdk installation(\jre\lib\ext folder) and add 10 jar files(main
Java program problem
Java program problem  Hi, I took the chance to login here in your educational page due to my questions in mind about my java programming assignment... is a path to a directory. Example: java DuplicateFinder c:\Documents
java sms problem
java sms problem  i am developing web site in which i have to maintain sms system where one can message his/her detail and it should be stored in the database.please give me some idea how to maintain it as i am beginner.Thank you
java array problem
java array problem  suppose i have an array a[] at a[0] i have value 5,7 the thing is that i want to assign the value of array a[0]=5,7 to two variable let it be j,k that is j=5 and k=7 plz help regards
Java I/O problem
Java I/O problem   Write a Java application that prompts the user to input their Name, Address, Date of Birth and Student ID number using the standard input - this information should then be saved to a file named studentData
Java IF statement problem
Java IF statement problem  Dear Sir/Madam i am using the following code. expected to not have any output but it still showing "welcome".. please help me why it showing "welcome". class c1 { int a=5; while(a>1
java core basic problem
java core basic problem  my question is: write a program that illustrates interface inheritance. interface P is extended by P1 and P2. interface... methode. class Q impliments P12 Instantiate Q and invoke each of its methods.Each
java core basic problem
java core basic problem  my question is: write a program that illustrates interface inheritance. interface P is extended by P1 and P2. interface... methode. class Q impliments P12 Instantiate Q and invoke each of its methods.Each
Java code problem
Java code problem  Please check the errors,if any,in this code...i am a java beginner import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.Map
Java HashSet Collection problem
Java HashSet Collection problem  Here's how the HashSet works. It maintains an array of buckets. When an object is inserted, it finds the appropriate bucket corresponding to the objects HashCode. Then it calls the equals method
java textfield problem
java textfield problem  I want to navigate the content of text field from one class to another and viceversa through button but when I am getting the text from first class I am getting null value.please help is the code
Java Web Browser Problem
Java Web Browser Problem  Hello When run my web browser this is not displaying complete page any of the website like other browser.So Plz help me. package vision.sun; import java.awt.Container; import
Java Servlet Problem - JSP-Servlet
Java Servlet Problem  I have a servlet class that implemets... method. Please help!!  Hi friend, Please explain problem in details for complete solution and send code the where are you problem. Thanks